Exp 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Name: Yash Patil

Class: TE-Comps-A
Roll No: 57

Experiment no: 02
#Hotel Occupancy

A) To create a table hotel


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 );

Inserting values into table


Query:
INSERT INTO Room(Room_id ,Room_type ,Max_occupant ,No_of_beds ,Room_side ,AC
,Renovation_year)
VALUES(110,'All-suite',1,6,'La 2',1,2004);
INSERT INTO Room(Room_id ,Room_type ,Max_occupant ,No_of_beds ,Room_side ,AC
,Renovation_year)
VALUES(234,'Double',2,7,'Sea',
2,2022);
INSERT INTO Room(Room_id ,Room_type ,Max_occupant ,No_of_beds ,Room_side ,AC
,Renovation_year)
VALUES(222,'Ex-suite',3,8,'Drive thru',3,2020);
INSERT INTO Room(Room_id ,Room_type ,Max_occupant ,No_of_beds ,Room_side ,AC
,Renovation_year)
VALUES(210,'Apt style',4,9,'Studio',4,2009);
INSERT INTO Room(Room_id ,Room_type ,Max_occupant ,No_of_beds ,Room_side ,AC
,Renovation_year)
VALUES(239,'penthouse-style',5,10,'Spa',5,2010);
C)To create table Customer
3.Query:
CREATE TABLE Customer
(Customer_id int PRIMARY KEY,
Customer_name varchar(50) NOT NULL,
Address varchar(50)NOT NULL,
Type_of_stay varchar(50) NOT NULL,
check_in int,
check_out int,
Amount_paid int);

Inserting values into table


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),

-- Set 2 (Changing values)


(101, 201, 301, '2023-08-02', 8, 7),
(101, 202, 302, '2023-08-02', 14, 1),
(101, 203, 303, '2023-08-02', 19, 1),
(101, 204, 304, '2023-08-02', 6, 9),
(101, 205, 305, '2023-08-02', 1, 14),

-- Set 3 (Changing values)


(101, 201, 301, '2023-08-03', 12, 3),
(101, 202, 302, '2023-08-03', 16, 1),
(101, 203, 303, '2023-08-03', 18, 2),
(101, 204, 304, '2023-08-03', 7, 8),
(101, 205, 305, '2023-08-03', 3, 12),

-- Set 4 (Changing values)


(101, 201, 301, '2023-08-04', 11, 4),
(101, 202, 302, '2023-08-04', 13, 2),
(101, 203, 303, '2023-08-04', 17, 1),
(101, 204, 304, '2023-08-04', 8, 7),
(101, 205, 305, '2023-08-04', 2, 13),

-- Set 5 (Changing values)


(101, 201, 301, '2023-08-05', 9, 6),
(101, 202, 302, '2023-08-05', 12, 3),
(101, 203, 303, '2023-08-05', 16, 1),
(101, 204, 304, '2023-08-05', 9, 6),
(101, 205, 305, '2023-08-05', 4, 11);

You might also like