0% found this document useful (0 votes)
5 views2 pages

TheoryMidterm CSC371

The document outlines the midterm examination details for the Databases-1 course at COMSATS University Islamabad, including instructions, questions, and marks distribution. It features questions on relational database concepts, SQL script writing, relational algebra operations, and SQL queries related to hotel and room management. The exam is scheduled for 90 minutes with a maximum score of 50 marks.

Uploaded by

Roman Regin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

TheoryMidterm CSC371

The document outlines the midterm examination details for the Databases-1 course at COMSATS University Islamabad, including instructions, questions, and marks distribution. It features questions on relational database concepts, SQL script writing, relational algebra operations, and SQL queries related to hotel and room management. The exam is scheduled for 90 minutes with a maximum score of 50 marks.

Uploaded by

Roman Regin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

COMSATS University Islamabad, Lahore Campus

Department of Electrical and Computer Engineering

Midterm Examination – Spring 2024


Course Title: Databases-1 Course Code: CSC 371 Credit Hours: 4(3,1)
Course Instructor: Modassir Ishfaq Programme Name: BCE
Semester: N/A Batch: Fa22 Section: A/B Date: 29-10-2024
Time Allowed: 90 Minutes Maximum Marks: 50
Student’s Name: Reg. No. CUI/…………………………../LHR
Important Instructions / Guidelines:
 Smart Gadgets are strictly not allowed during examination.
 Adhere to the protocols laid by the examination department.

Question 1: (12 Marks)

The following tables form part of a database held in a relational DBMS:


Hotel (hotelNo, hotelName, city)
Room (roomNo, hotelNo, type, price)
Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)
Guest (guestNo, guestName, guestAddress)
where
Hotel contains hotel details and hotelNo is the primary key;
Room contains room details for each hotel and (roomNo, hotelNo) forms the primary key;
Booking contains details of bookings and (hotelNo, guestNo, dateFrom) forms the primary key;
Guest contains guest details and guestNo is the primary key.

A. Identify the foreign keys (3)


B. Identify the degree and cardinality of relationships between the entities
(3)
C. Provide verbs for every relationship (2)
D. Produce an entity relationship diagram. (4)

Question 2: (8 Marks)

For the schema provided in Q.1, write an SQL script to create the tables. Implement, where possible, the keys and
other constraints and enforce the relationships as per ERD devised in Q1.D. All constraints must be added after
the tables are created using separate SQL queries.

Question 3: (10 Marks/ 2.5 Marks


each)

A. Consider the relational schema discussed in Q.1. Describe the relations that would be produced by the
following relational algebra operations:
a. ΠhotelNo(σprice > 50(Room))
Projects hotelNo. From table ‘room’ which have rooms with price higher than 50
b. σHotel.hotelNo = Room.hotelNo(Hotel × Room)
cartesian product of hotel and room and only those rows are selected where hotel number
is same in both tables. It simulates a join between hotel and room based on hotelnumber
and returns all hotels and their room details
B. Generate the relational algebra for the following queries:
a. List all single rooms with a price below $20 per night
ΠroomNo,type,price(σprice<20 (Room))
b. List the price and type of all rooms at The Ritz hotel
ΠroomNo,price,type (σhotel.name=’The Ritz Hotel’ (σHotel.hotelNo = Room.hotelNo (room x hotel)))

Question 4: (20 Marks / 2 Marks


each)

Considering the relational schema provided in Q1., write SQL queries to extract the following information;

A. List all double or family rooms priced below $40 per night, in ascending order
B. How many hotels are listed?
C. Update the price of all rooms of “Avari Hotel” by 10%
D. Insert a new hotel that has only 2 rooms.
E. What is the average price of the room?
F. List the details of all rooms at the “Hilton Hotels”, including the name of the guest staying in the room if
the room is occupied.
G. List the rooms, their type and price that are unoccupied at the “Hilton Hotels”
H. What is the total income from bookings at the “Ritz hotels” today
I. Change the table of guests so that their phone number can be stored as well.
J. List the names of those hotels which offer rooms below the average price of rooms.

You might also like