CS3010301 Database Systems
Final
Spring 2022
SID# & Name:
1. (20%) For the follow schedule with the given initial values, decide whether
a. (10%) the schedule is serializable
b. (10%) the schedule can be produced by a Two Phase Locking (2PL) scheduler
You need to justify your answers to receive full credits.
You can use the empty space in the schedule to place lock/unlock operations for your answers.
Initial values:
A=50
B=10
C=20
D=30
Page 1 of 4
2. (20%) Suppose you are given a relation R with four attributes (WXYZ). For each of the following
sets of FDs, assuming those are the only dependencies that hold for R, do the following: (1)
Identify the candidate key(s) for R. (2) Identify the best normal form that R satisfies (1NF, 2NF,
3NF, or BCNF). (3) If R is not in BCNF, decompose it into a set of BCNF relations that preserve
the dependencies.
a. (10%) W → X, ZYX → W
b. (10%) ZW → Y, X → Z, X → W
3. (30%) Consider the following schema:
supplier (sid, sname, address)
part (pid, pname, color)
catalog (sid, pid, cost)
The key fields are underlined. The catalog relation lists the prices charged for parts by
suppliers. Formulate the following queries. If the query cannot be formulated, briefly explain
why.
a. (10%) Write the query “Find the addresses of suppliers whose name is “Wells Fargo” or
supply some red parts” in SQL.
Page 2 of 4
b. (10%) Write the query “For each supplier, retrieve the name of supplier, and the average
cost of red parts sold by the supplier” in SQL.
c. (10%) Write the query “Find pairs of supplier ids such that the supplier with the first sid
charges more for the same parts than the supplier with the second sid” in SQL.
4. (20%) Consider the following SQL query:
SELECT E.Fname, E.Lname, E.Address
FROM EMPLOYEE E, PROJECT P, WORK_ON W
WHERE P.Pname = “Mars” AND W.Pno = P.Pnumber AND
E.Salary > 20000 AND E.Ssn = W.Essn;
(a) (5%) Draw the query graph.
(b) (15%) Draw the initial query tree and the optimized query tree using heuristic optimization.
Briefly explain your assumptions.
Page 3 of 4
5. (10%) Consider the concurrent transaction processing log shown below. Suppose that we use the
in-place deferred update protocol with checkpointing.
Step Log Entry
1 <T1, start>
2 <T1, Z, 3, 5>
3 <T2, start>
4 <T1, commit>
5 <checkpoint>
6 <dump>
7 <T2, Z, 5, 2>
8 <T3, start>
9 <T3, X, 3, 4>
10 <T4, start>
11 <T4, X, 4, 5>
12 <T2, commit>
crash
13 <T3, Y, 1, 2>
14 <T4, Y, 2, 5>
Give recovery actions AND the log entries required for EACH transaction given the event of failure
(RAM lost) between step 12 and 13. Briefly explain why.
Page 4 of 4