 	CONSTRAINT pk_reservations PRIMARY KEY ( id )
  );
 
-CREATE INDEX idx_reservation ON reservations ( id_room );
-
-CREATE INDEX idx_reservation_0 ON reservations ( id_guest );
-
-CREATE INDEX idx_reservations ON reservations ( id_notification );
-
-ALTER TABLE cooperating_companies ADD CONSTRAINT fk_cooperating_companies_emplyee FOREIGN KEY ( responsible_worker ) REFERENCES employees( id );
-
-COMMENT ON CONSTRAINT fk_cooperating_companies_emplyee ON cooperating_companies IS '';
-
-ALTER TABLE departments ADD CONSTRAINT fk_sections_leader FOREIGN KEY ( leader ) REFERENCES employees( id );
-
-COMMENT ON CONSTRAINT fk_sections_leader ON departments IS '';
-
-ALTER TABLE employees ADD CONSTRAINT fk_employees_sections FOREIGN KEY ( id_department ) REFERENCES departments( id );
-
-COMMENT ON CONSTRAINT fk_employees_sections ON employees IS '';
-
-ALTER TABLE facilities ADD CONSTRAINT fk_facilities_employee FOREIGN KEY ( responsible_worker ) REFERENCES employees( id );
-
-COMMENT ON CONSTRAINT fk_facilities_employee ON facilities IS '';
-
-ALTER TABLE guests ADD CONSTRAINT fk_leaders FOREIGN KEY ( booker ) REFERENCES guests( id );
-
-COMMENT ON CONSTRAINT fk_leaders ON guests IS '';
-
-ALTER TABLE notifications ADD CONSTRAINT fk_notifications_section FOREIGN KEY ( id_department ) REFERENCES departments( id );
-
-COMMENT ON CONSTRAINT fk_notifications_section ON notifications IS '';
-
-ALTER TABLE notifications ADD CONSTRAINT fk_notifications_type FOREIGN KEY ( id_type ) REFERENCES notification_types( id );
-
-COMMENT ON CONSTRAINT fk_notifications_type ON notifications IS '';
-
-ALTER TABLE orders ADD CONSTRAINT fk_orders_categories FOREIGN KEY ( id_order_categories ) REFERENCES order_categories( id );
-
-COMMENT ON CONSTRAINT fk_orders_categories ON orders IS '';
-
-ALTER TABLE orders ADD CONSTRAINT fk_orders_guests FOREIGN KEY ( id_guest ) REFERENCES guests( id );
-
-COMMENT ON CONSTRAINT fk_orders_guests ON orders IS '';
-
-ALTER TABLE orders ADD CONSTRAINT fk_orders_not FOREIGN KEY ( id_notification ) REFERENCES notifications( id );
-
-COMMENT ON CONSTRAINT fk_orders_not ON orders IS '';
-
-ALTER TABLE payments ADD CONSTRAINT fk_payments_orders FOREIGN KEY ( id_order ) REFERENCES orders( id );
-
-COMMENT ON CONSTRAINT fk_payments_orders ON payments IS '';
-
-ALTER TABLE photos ADD CONSTRAINT fk_galery_fac FOREIGN KEY ( id_facility ) REFERENCES facilities( id );
-
-COMMENT ON CONSTRAINT fk_galery_fac ON photos IS '';
-
-ALTER TABLE reservations ADD CONSTRAINT fk_reservation_room FOREIGN KEY ( id_room ) REFERENCES rooms( id );
-
-COMMENT ON CONSTRAINT fk_reservation_room ON reservations IS '';
-
-ALTER TABLE reservations ADD CONSTRAINT fk_reservation_guest FOREIGN KEY ( id_guest ) REFERENCES guests( id );
-
-COMMENT ON CONSTRAINT fk_reservation_guest ON reservations IS '';
-
-ALTER TABLE reservations ADD CONSTRAINT fk_reservations_not FOREIGN KEY ( id_notification ) REFERENCES notifications( id );
-
-COMMENT ON CONSTRAINT fk_reservations_not ON reservations IS '';
-
-ALTER TABLE rooms ADD CONSTRAINT fk_rooms FOREIGN KEY ( id_class ) REFERENCES classes( id );
-
-COMMENT ON CONSTRAINT fk_rooms ON rooms IS '';
-
+CREATE INDEX idx_reservation ON reservation ( id_room );
+
+CREATE INDEX idx_reservation_0 ON reservation ( id_guest );
+
+CREATE INDEX idx_reservations ON reservation ( id_notification );
+
+ALTER TABLE cooperating_company ADD CONSTRAINT fk_cooperating_companies_emplyee FOREIGN KEY ( responsible_worker ) REFERENCES employee( id );
+
+COMMENT ON CONSTRAINT fk_cooperating_companies_emplyee ON cooperating_company IS '';
+
+ALTER TABLE department ADD CONSTRAINT fk_sections_leader FOREIGN KEY ( leader ) REFERENCES employee( id );
+
+COMMENT ON CONSTRAINT fk_sections_leader ON department IS '';
+
+ALTER TABLE employee ADD CONSTRAINT fk_employees_sections FOREIGN KEY ( id_department ) REFERENCES department( id );
+
+COMMENT ON CONSTRAINT fk_employees_sections ON employee IS '';
+
+ALTER TABLE facility ADD CONSTRAINT fk_facilities_employee FOREIGN KEY ( responsible_worker ) REFERENCES employee( id );
+
+COMMENT ON CONSTRAINT fk_facilities_employee ON facility IS '';
+
+ALTER TABLE facility ADD CONSTRAINT fk_facility_photo FOREIGN KEY ( id_photo ) REFERENCES photo( id );
+
+COMMENT ON CONSTRAINT fk_facility_photo ON facility IS '';
+
+ALTER TABLE guest ADD CONSTRAINT fk_leaders FOREIGN KEY ( booker ) REFERENCES guest( id );
+
+COMMENT ON CONSTRAINT fk_leaders ON guest IS '';
+
+ALTER TABLE guest ADD CONSTRAINT fk_guests_users FOREIGN KEY ( user_id ) REFERENCES user( id );
+
+COMMENT ON CONSTRAINT fk_guests_users ON guest IS '';
+
+ALTER TABLE notification ADD CONSTRAINT fk_notifications_section FOREIGN KEY ( id_department ) REFERENCES department( id );
+
+COMMENT ON CONSTRAINT fk_notifications_section ON notification IS '';
+
+ALTER TABLE notification ADD CONSTRAINT fk_notifications_type FOREIGN KEY ( id_type ) REFERENCES notification_type( id );
+
+COMMENT ON CONSTRAINT fk_notifications_type ON notification IS '';
+
+ALTER TABLE order ADD CONSTRAINT fk_orders_categories FOREIGN KEY ( id_order_category ) REFERENCES order_category( id );
+
+COMMENT ON CONSTRAINT fk_orders_categories ON order IS '';
+
+ALTER TABLE order ADD CONSTRAINT fk_orders_guests FOREIGN KEY ( id_guest ) REFERENCES guest( id );
+
+COMMENT ON CONSTRAINT fk_orders_guests ON order IS '';
+
+ALTER TABLE order ADD CONSTRAINT fk_orders_not FOREIGN KEY ( id_notification ) REFERENCES notification( id );
+
+COMMENT ON CONSTRAINT fk_orders_not ON order IS '';
+
+ALTER TABLE payment ADD CONSTRAINT fk_payments_orders FOREIGN KEY ( id_order ) REFERENCES order( id );
+
+COMMENT ON CONSTRAINT fk_payments_orders ON payment IS '';
+
+ALTER TABLE reservation ADD CONSTRAINT fk_reservation_room FOREIGN KEY ( id_room ) REFERENCES room( id );
+
+COMMENT ON CONSTRAINT fk_reservation_room ON reservation IS '';
+
+ALTER TABLE reservation ADD CONSTRAINT fk_reservation_guest FOREIGN KEY ( id_guest ) REFERENCES guest( id );
+
+COMMENT ON CONSTRAINT fk_reservation_guest ON reservation IS '';
+
+ALTER TABLE reservation ADD CONSTRAINT fk_reservations_not FOREIGN KEY ( id_notification ) REFERENCES notification( id );
+
+COMMENT ON CONSTRAINT fk_reservations_not ON reservation IS '';
+
+ALTER TABLE room ADD CONSTRAINT fk_room_standard FOREIGN KEY ( id_standard ) REFERENCES standard( id );
+
+COMMENT ON CONSTRAINT fk_room_standard ON room IS '';
+
+ALTER TABLE room ADD CONSTRAINT fk_room_photo FOREIGN KEY ( id_photo ) REFERENCES photo( id );
+
+COMMENT ON CONSTRAINT fk_room_photo ON room IS '';
+
+ALTER TABLE session ADD CONSTRAINT fk_session_user FOREIGN KEY ( user_id ) REFERENCES user( id );
+
+COMMENT ON CONSTRAINT fk_session_user ON session IS '';
+

	CONSTRAINT pk_employees PRIMARY KEY ( id )
 );

CREATE INDEX idx_employees ON employees ( id_department );

COMMENT ON COLUMN employees.bonus IS 'Bonus to salary';

CREATE TABLE facilities ( 
	id                   serial  NOT NULL,
	name                 varchar(200)  NOT NULL,
	description          text  ,
	responsible_worker   integer  ,
	CONSTRAINT pk_facilities PRIMARY KEY ( id )
 );

CREATE INDEX idx_facilities ON facilities ( responsible_worker );

CREATE TABLE guests ( 
	id                   serial  NOT NULL,
	name                 varchar(200)  NOT NULL,
	phone                varchar(50)  NOT NULL,
	mail                 varchar(100)  ,
	booker               integer  NOT NULL,
	CONSTRAINT pk_guests PRIMARY KEY ( id )
 );

CREATE INDEX idx_guests ON guests ( booker );

CREATE TABLE notifications ( 
	id                   serial  NOT NULL,
	id_type              integer  ,
	id_department        integer  ,

	CONSTRAINT pk_notifications PRIMARY KEY ( id )
 );

CREATE INDEX idx_notifications ON notification ( id_department );

CREATE INDEX idx_notifications_0 ON notification ( id_type );

CREATE TABLE order ( 
	id                   serial  NOT NULL,
	id_guest             integer  NOT NULL,
	received_date        date  ,
	id_order_category    integer  NOT NULL,
	id_notification      integer  NOT NULL,
	CONSTRAINT pk_orders PRIMARY KEY ( id )
 );

CREATE INDEX idx_orders ON order ( id_order_category );

CREATE INDEX idx_orders_0 ON order ( id_guest );

CREATE INDEX idx_orders_1 ON order ( id_notification );

CREATE TABLE payment ( 
	id                   serial  NOT NULL,
	id_order             integer  NOT NULL,
	amount               numeric(8,2)  NOT NULL,
