You are on page 1of 12

Foundation University Islamabad

Rawalpindi Campus
Final Term Examination – Spring 2020
NAME: M-Awais-Zia (149) Semester: 4th

Course Title: Database Systems LAB (CSC-224L) Section: B

Course Instructors: Saqib Nazir Roll Number: 149

Time Allowed: 180 minutes Date: August 19, 20

Candidate Name: Muhammad Awais Zia Candidate ID: 149

INSTRUCTIONS
− Attempt all questions. Be brief and to the point
− Avoid Cutting, erasing, and over-writing
− Think and compile the answer in your mind before writing it
− Follow sequence of the questions while attempting them

Q#1 [2.5 * 8 = 20]


Write SQL queries for following statements using the schema given below.

Schema
Hotel (hotelNo, hotelName, city)
Room (roomNo, hotelNo, type, price)
Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)
Guest (guestNo, guestName, guestAddress)

Queries
i. Update the price of all rooms by 5%.
ii. List the details of all rooms at the Grosvenor Hotel, including the name of the guest staying in the room, if the
room is occupied.
iii. What is the most commonly booked room type for each hotel in London.
iv. List all double or family rooms with a price below £40.00 per night, in ascending order of price.
v. What is the total revenue per night from all double rooms?
vi. For each branch office with more than one member of staff, find the number of staff working in each branch and
the sum of their salaries
vii. For each branch, list the staff numbers and names of staff who manage properties, including the city in which the
branch is located and the properties that the staff manage
viii. Find the number of properties handled by each staff member, along with the branch number of the member of
staff
Q#2 [2 * 5 = 10]

Consider the relation instances given below to show output of following queries.

i. SELECT b.branchNo, b.city, s.staffNo, fName, IName, propertyNo FROM Branch b, Staff s, PropertyForRent
p
WHERE b.branchNo = s.branchNo AND s.staffNo = p.staffNo
ORDER BY b.branchNo, s.staffNo, propertyNo

ii. SELECT staffNo, fName, IName, position, salary FROM Staff WHERE
salary > SOME (SELECT salary FROM Staff WHERE branchNo = ‘B003’)

iii. SELECT propertyNo, street, city, postcode, type, rooms, rent FROM PropertyForRent
WHERE staffNo IN (SELECT staffNo FROM Staff
WHERE branchNo = (SELECT branchNo FROM Branch
WHERE street = ‘163 Main St’))

iv. SELECT staffNo, fName, IName, position, salary – (SELECT AVG(salary) FROM Staff) AS salDiff
FROM Staff
WHERE salary > (SELECT AVG(salary) FROM Staff)
v. SELECT COUNT(DISTINCT propertyNo) AS myCount FROM Viewing WHERE viewDate BETWEEN
‘1-May-13’ AND ‘31-May-13’
Q#3 [5]

Write down the PHP code which verifies the email address and password and opens a new form if they are correct and
give error message if they are wrong.
User Name: saqib@gmail.com Password: final

You might also like