QUESTION
QUESTION
QUESTION
Note: There are 5 (FIVE) questions, answer ALL of them. Course Outcome (CO), Cognitive Level and Mark
of each question are mentioned at the right margin.
1. Assume that you are the owner of a very popular online grocery store. Every day, [CO1, C3,
your store has thousands of transactions and therefore, inserting a lot of data into Mark: 5]
your database. Among this data, some are very sensitive which must not be
accessible by all employees of your store.
How can you provide this security by hiding some part of the database? Justify
your answer briefly by using relevant terms.
The Booking relation contains booking information such as guest id, room number,
hotel id, check-in date and check-out date from the hotel. A guest is not allowed to
book the same hotel room with the same check-in date, but she can book the same
hotel room with different check-in date.
Draw the schema diagram of the given database. You must identify primary keys
and foreign keys appropriately.
Page 1 of 4
05/11/2020
4. Formulate Relational algebra expressions for the following queries based on the [CO1, C3,
‘MyHome’ database schema as given in Appendix. Mark: 10]
a) Find client names (both first and last) who can afford more than 500 as
maxRent and registerd in Branch ‘B003’.
b) Find the property with the minimum rent. Display propertyNo, postcode
and type. You must use RENAME operator.
c) Find client names (both first and last) who have ‘Flat’ preference (prefType)
and viewed (visited) some properties. You must use appropriate set
operator.
d) How many staffs are female?
e) Find the number of customers registered at each branch. Display branch city
as well.
5. Write SQL Statements for the following queries based on the ‘MyHome’ database [CO2, C3,
schema as given in Appendix. Mark: 10]
a) Find property details (propertyNo, street and city) which are ‘House’ type
and rent is less than 650.
b) Find client names (both first and last) and the staff names (both first and
last) who are assigned to those clients.
c) Find branchNo and city which have no registered customers. You must use
appropriate set operator.
d) Find staff names (both first and last) who are managers and their first name
starts with ‘J’ and has exactly four characters.
e) Find the number of properties and average rent of properties for each city.
Sort the result based on average rent in ascending order. Rename the column
heading of the result relation appropriately.
Page 2 of 4
05/11/2020
Appendix
MyHome Database
MyHome has many branches throughout the country. The relation Branch stores branch related
information.
The relation Staff holds staff related data and the branch number a staff is working on.
The relation Client holds client related data including their preferred accommodation type and the
maximum rent they can afford.
The relation PropertyForRent stores property related data about the location of the property, number
of available rooms and rent amount along with the owner number, branch number under which the
property is registered and the staff number who is the contact person for that property.
The relation Viewing stores data on each client’s visit on a property. A client can visit a property
multiple times, but not twice in a day. A client can make some comments about the property during
his/her visit.
The relation Registration contains data on clients’ registration including the client number, branch
number in which the client is registered, staff number who is the contact person for that client and the
date when the client registered. A client can register at multiple branches.
Page 3 of 4
05/11/2020
Page 4 of 4