Lab Report No 7 & 9: Introduction To Aggregation, Group By, and Joins, Views and Triggers
Lab Report No 7 & 9: Introduction To Aggregation, Group By, and Joins, Views and Triggers
Introduction to Aggregation,
Group By, and JOINs,
Views and Triggers
Submitted By
Farah Amber
2017-EE-104
SECTION : C
Submitted to:
Relational Schema:
Task 02:
Display the names of all the hotels along with the number of rooms present in each of
them.
TASK NO 3:
Display the AVG price of each hotel situated in London.
TASK NO 5:
Display hotelname, cityname along with distinct number of room types available in each
of them.
TASK NO 7:
Display the name, city of all the hotels along with the number of reservations it has, in
descending order.
TASK NO 9:
Display the HotelName and RoomNo which was reserved in either year 2003 or 2004,
also display the Guest No of the respective guest.
TASK NO 11:
How many different guests have made bookings till May, 2015?
TASK NO 14:
List the price and type of all rooms at the ‘Avari’ Hotel in Lahore.
TASK NO 16:
What is the total income from bookings for the ‘Hotel Inn’ Hotel today?
TASK NO 18:
What is the lost income from unoccupied rooms at the ‘Hotel Inn’ Hotel?
TASK NO 20:
For each hotel with more than two different types of rooms, what is the lost income from
unoccupied rooms?
TASK NO 2:
Use View to List the names and addresses of all guests in London, alphabetically
ordered by name.
TASK NO 4:
Insert a new tuple in VIEW2 by using “INSERT INTO VIEW2” command and check if
new data has updated the original table or not.
ANSWER:
We can not insert without the primary key .if I consider the primary key in view 2 , then
following as shown below:
2017-EE-104 (Farah Amber)
14 | P a g e
If consider the primary key then ,Yes, it updated the original table
TASK NO 5:
Yes. It updated the original database , as seen from the 3 rd row. price is updated there.
TASK NO 6: