19Cs2108S - Database Management Systems: Time: Max - Marks: 100
19Cs2108S - Database Management Systems: Time: Max - Marks: 100
1. Consider the following database schema (University Management System): student (ID, choice 10Marks CO1 3 1
name, dept_name, tot_cred) advisor (s_id, i_id) takes (ID, course_id, sec_id, semester, Q-2
year, grade) classroom (building, roomnumber, capacity) timeslot (timeslot_id, day,
start_time, end_time) section (course_id, sec_id, semester, year, building, roomnumber,
timeslot_id) teaches (ID, course_id, sec_id, semester, year) department (dept_name,
building, budget) instructor(ID, name, dept_name, salary) course(course_id, title,
dept_name, credits) prereq(course_id, prereq_id). Design an ER diagram for the above
scenario by identifying various constraints and relationships between the entities.
3. The loan office in a bank receives from various parties requests to investigate the credit choice 15Marks CO1 3 3
status of a customer. Each credit request is identified by a Request ID and is described Q-4
by a Request Date and Requesting Party Name. The loan office also received results of
credit checks. A credit check is identified by a Credit Check ID and is described by the
Credit Check Date and the Credit Rating. The loan office matches credit requests with
credit check results. A credit request may be recorded before its result arrives; a
particular credit result may be used in support of several credit requests. Design an ER
Diagram for this situation. Now, assume that credit results may not be reused for
multiple credit requests. Redesign the ER Diagram for this new situation using two
entity types, and then redraw it again using one entity type. Justify which among these
two versions do you prefer, Justify?
6. Consider the following relational schema Student(id, name), EnrolledIn (id, code) 10Marks CO2 3 3
Subject (code, lecturer). Given the above relation, and our university schema, write
each of the following queries in SQL. i. Find the names of students enrolled in cs3020?
ii. Which subjects is Hector taking? iii. List the lecturers who teach cs1500? iv. What are
the names of all the students? v. List all the lecturers who teach at least two different
subjects? vi. Find the names of students enrolled for a subject taught by Roger? vii. Find
the names of students in both cs1500 and cs1200? viii. What are the names of students
in at least two different subjects? ix. What are the codes of all the subjects taught?
7. Consider the following schema: Suppliers( sid: integer, sname: string, address: string) choice 15Marks CO2 3 3
Parts(pid: integer, pname: string, color: string) Catalog( sid: integer, pid: integer, cost: Q-8
real) The Catalog relation lists the prices charged for parts by Suppliers. Write
Relational Algebra expressions for the following 1. Find the pnames of parts for which
there is some supplier. 2. Find the snames of suppliers who supply every part. 3. Find
the snames of suppliers who supply every red part. 4. Find the pnamcs of parts
supplied by Acme Widget Suppliers and no one else. 5. Find the sids of suppliers who
charge more for some part than the average cost of that part (averaged over all the
suppliers who supply that part). 6. For each part, find the sname of the supplier who
charges the most for that part. 7. Find the sids of suppliers who supply only red parts.
8. Find the sids of suppliers who supply a red part and a green part. 9. Find the sids of
suppliers who supply a red part or a green part. 10. For every supplier that only
supplies green parts, print the name of the supplier and the total number of parts that
she supplies
8. Model the following queries in the Relational Algebra using below relational schema? 15Marks CO2 3 3
Product (maker, model, type), PC(model, speed, ram, hd, price), Laptop(model, speed,
ram, hd, screen, price), Printer(model, color, type, price). i. Find the model number,
speed, and hard-disk size for all PC’s whose price is under $1000. ii. Find the
manufacturers of printers. ii. Find the model number, memory size, and screen size for
laptops costing more than $1500. iv. Find all the PCs whose cost is in the range 20000
to 40000. v. Find the model number and hard-disk size for those PC’s that have a speed
of 3.2 and a price less than $2000. vi. Give the manufacturer and speed of laptops with
a hard disk of at least thirty gigabytes. vii. Find the model number and price of all
products (of any type) made by manufacturer B. viii. Find the makers of PC’s with a
speed of at least 3.0. ix. Find the makers who produces both PC and Laptop with ram
greater than 2GB.
9. Consider a relation R with five attributes ABCDE. You are given the following choice 10Marks CO3 4 1
dependencies: A --t B, Be ~ B, and BD ~ A. 1. List all keys for R. 2. Is R in :3NF? 3. Is R in Q-10
BCNF?
12. Suppose you are given a relation StaffPropertylnspection (propertyNo, iDate, iTime, 15Marks CO3 4 4
pAddress, comments, staffNo, sName, carReg) with the following functional
dependencies: : FD1: propertyNo, iDate -> iTime, comments, staffNo, sName, carReg
FD2 : propertyNo -> pAddress FD3 : staffNo -> sName FD4 : staffNo, iDate -> carReg
FD4 : carReg, iDate, iTime -> propertyNo, pAddress, comments, staffNo, sName FD6 :
staffNo, iDate, iTime -> propertyNo, pAddress, comments i. Find all candidate keys? ii.
Identify the best normal form that StaffPropertylnspection satisfies (1NF, 2NF, 3NF, or
BCNF)? iii. If the relation is not in BCNF, decompose it until it becomes BCNF. At each
step, identify a new relation, decompose and recompute the keys and the normal
forms they satisfy?
13. Analyze the following schedules and determine which of them is (conflict) serializable? choice 10Marks CO4 4 1
For each serializable schedule, determine the equivalent serial schedules. a. r1(X); r3(X); Q-14
w1(X); r2(X); w3(X); b. r1(X); r3(X); w3(X); w1(X); r2(X); c. r3(X); r2(X); w3(X); r1(X); w1(X); d.
r3(X); r2(X); r1(X); w3(X); w1(X);
15. Consider the execution of two transactions T1 and T2 assume that if the initial values of choice 15Marks CO4 4 4
X, Y, M and N are 100, 800, 10, 45 respectively. i. Write the final values of X and Y as per Q-16
schedule A. Is this a serializable schedule? ii. Write the final values of X and Y for all
possible serial schedules as per schedule B
16. A DBMS attempts to run the following schedule. Show: (I) How conservative 2PL would 15Marks CO4 4 4
prevent deadlock. (II) .How ordering all data items would prevent deadlock. (III) How
the wait-for scheme would prevent deadlock. (IV) How the wound-wait scheme would
prevent deadlock.