The document describes creating tables to store hotel, room, customer, and time data, as well as a fact table to track hotel occupancy. Tables are created for hotel, room, customer, and time, with attributes like hotel name, room type, customer address, and date. The fact table tracks occupied and vacant rooms by hotel, room, customer, and date. Sample data is inserted into each table.
The document describes creating tables to store hotel, room, customer, and time data, as well as a fact table to track hotel occupancy. Tables are created for hotel, room, customer, and time, with attributes like hotel name, room type, customer address, and date. The fact table tracks occupied and vacant rooms by hotel, room, customer, and date. Sample data is inserted into each table.
The document describes creating tables to store hotel, room, customer, and time data, as well as a fact table to track hotel occupancy. Tables are created for hotel, room, customer, and time, with attributes like hotel name, room type, customer address, and date. The fact table tracks occupied and vacant rooms by hotel, room, customer, and date. Sample data is inserted into each table.
The document describes creating tables to store hotel, room, customer, and time data, as well as a fact table to track hotel occupancy. Tables are created for hotel, room, customer, and time, with attributes like hotel name, room type, customer address, and date. The fact table tracks occupied and vacant rooms by hotel, room, customer, and date. Sample data is inserted into each table.
1. Query: CREATE TABLE hotel (hotel_id int PRIMARY KEY, hotel_name varchar(50) NOT NULL, Rooms int, hotel_type varchar(50) NOT NULL, star_rating int, Region varchar(50) NOT NULL, City varchar(50) NOT NULL, state varchar(50) NOT NULL );
Inserting Values into table:
Query: INSERT INTO hotel(hotel_id,hotel_name, Rooms ,hotel_type ,star_rating ,Region ,City ,state ) VALUES(1,'Fern',50,'Inn',3,'Sector 45','Mumbai','Maharashtra'); INSERT INTO hotel(hotel_id,hotel_name,Rooms ,hotel_type ,star_rating ,Region ,City ,state ) VALUES (2,'Fountain',30,'Suite',4,'NH 47','Banglore','Karnataka'); INSERT INTO hotel(hotel_id,hotel_name,Rooms ,hotel_type ,star_rating ,Region ,City ,state ) VALUES(3,'Atlantis',1500,'Chain',7,'Near Yal Island','Jumeirah','UAE'); INSERT INTO hotel(hotel_id,hotel_name,Rooms ,hotel_type ,star_rating ,Region ,City ,state ) VALUES(4,'Taj',45,'Motels',2,'Old Road 45','Agra','UP'); INSERT INTO hotel(hotel_id,hotel_name,Rooms ,hotel_type ,star_rating ,Region ,City ,state ) VALUES(5,'Orchard',120,'Luxurious',6,'HSBC 2','Collever','Singapore'); B) To create a table Room 2. Query: CREATE TABLE ROOM ( Room_id int PRIMARY KEY, Room_type varchar(50) NOT NULL, Max_occupant int, No_of_beds int, Room_side varchar(50) NOT NULL, AC varchar(1) NOT NULL, Renovation_year int );
Query: INSERT INTO Customer(Customer_id,Customer_ name,Address ,Type_of_stay ,check_in ,check_out ,Amount_paid ) VALUES(1234,'Shara','A1 Mariana apt','a week',12,11,1200); INSERT INTO Customer(Customer_id,Customer_name,Address ,Type_of_stay ,check_in ,check_out ,Amount_paid ) VALUES (5677,'Arya','C 20 Anand apt','day',1,10,1550); INSERT INTO Customer(Customer_id,Customer_name,Address ,Type_of_stay ,check_in ,check_out ,Amount_paid ) VALUES(1204,'Jui','D 12 Hiranandani','2 days',2,9,20000); INSERT INTO Customer(Customer_id,Customer_name,Address ,Type_of_stay ,check_in ,check_out ,Amount_paid ) VALUES(2503,'Abhimanyu','B 6 Lodha','3 days',3,6,3500); INSERT INTO Customer(Customer_id,Customer_name,Address ,Type_of_stay ,check_in ,check_out ,Amount_paid ) VALUES(1306,'Tara','C wing Avasari','a month',4,8,4000); D) To create table time 4. Query: CREATE TABLE Time (Date date PRIMARY KEY, Day_of_week int, Day_of_month int, Week int, Month int, Year int);
Inserting values into table
Query: INSERT INTO Time(Date,Day_of_week,Day_of_ month,Week,Month,Year) VALUES('2000-12-02',5,02,4,12,2000); INSERT INTO Time(Date,Day_of_week,Day_of_month,Week,Month,Year) VALUES('2014-01-20',4,20,3,01,2014); INSERT INTO Time(Date,Day_of_week,Day_of_month,Week,Month,Year) VALUES('2003-04-12',2,12,2,04,2003); INSERT INTO Time(Date,Day_of_week,Day_of_month,Week,Month,Year) VALUES('2003-03-25',7,25,1,03,2003); INSERT INTO Time(Date,Day_of_week,Day_of_month,Week,Month,Year) VALUES('2020-11-22',6,22,4,11,2020);
Fact Table of Hotel Occupancy
Create a fact table: Query: CREATE TABLE Fact_occup (hotel_id int REFERENCES hotel(hotel_id), Room_id int REFERENCES Room(Room_id), Customer_id int REFERENCES Customer(Customer_id), Date date REFERENCES Time(Date), Number_of_occupied_rooms int NOT NULL, Number_of_vacant_rooms int NOT NULL); Inserting values into fact table Query: INSERT INTO fact_jui (hotel_id, room_id, customer_id, date, number_of_occupied_rooms, number_of_vacant_rooms) VALUES -- Set 1 (101, 201, 301, '2023-08-01', 10, 5), (101, 202, 302, '2023-08-01', 15, 0), (101, 203, 303, '2023-08-01', 20, 0), (101, 204, 304, '2023-08-01', 5, 10), (101, 205, 305, '2023-08-01', 0, 15),