Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[ Question 1 ] Consider the following relational schema: Student ( S# , Sname, Dept ) Prof ( P# , Pname, Dept, Salary ) Course

[Question 1] Consider the following relational schema:
Student (S#, Sname, Dept) Prof (P#, Pname, Dept, Salary)
Course (C#, Cname, Text) St-Course (S#, C#) Prof-Course (P#, C#)
For the following SQL query
SELECT Sname
FROM Student, Prof, St-Course, Prof-Course
WHERE (Student.Dept = Prof. Dept OR
(Prof.Salary >100 AND Student.Dept = Prof. Dept))
AND Prof. P# = Prof.Course.P#
AND Prof-Course.C# = St-Course.C#
AND St-Course.S# = Student.S#
(1-a) Write the initial query tree corresponding to the above SQL query.
(1-b) Apply query optimization heuristics on the tree to produce the most efficient
query tree.
(1-c) Write the Relational Algebra query corresponding to the most efficient tree.
2
[Question 2] Find out if the following schedules are conflict serializable or not? If
a schedule is conflict serializable, get its corresponding serial schedule: [Hint:
assuming all transactions are committed at the end of the schedule]
a. R1(x), R2(x), W1(x), R3(x), W3(x)
b. R1(x), R2(x), W2(x), W1(x), R3(x)
c. R3(x), R1(x), W3(x), R2(x), W1(x)
d. R3(x), R1(x), R2(x), W3(x), W1(x)
e. R1(x), R2(z), R3(z), R3(x), R3(y), W1(x), W3(y), R2(y), W2(z), W2(y)
f. R1(x), R2(z), R3(x), R1(z), R2(x), R3(y), W1(x), W2(z), W3(y), W2(y)
[Question 3] Consider the following three transactions:
T1: R1(x), R1(z), W1(x), C1
T2: R2(z), R2(x), W2(z), W2(y) C2
T3: R3(x), R3(y), W3(y), C3
(3-a) Add Locks and Unlocks to each transaction such that the transaction follows
the 2PL protocol.
(3-b) Add Locks and Unlocks to each transaction such that the transaction follows
the Strict 2PL protocol (S2PL).
(3-c) Add Locks and Unlocks to each transaction such that the transaction follows
the Rigours 2PL protocol (R2PL).
(3-d) Write a possible schedule that may be produced by each locking protocol
2PL, S2PL, R2PL.
(3-e) Show whether the schedule is deadlock free or not.
3
[Question 4] Consider the following schedule where, for clarity, we have included
all the operations that will appear in the log, plus additional helpful detail.
Operation Column 2
T1 STARTS
T1 reads item B
T1 writes item B with old value 11, new value 12
T2 STARTS
T2 reads item B
T2 writes item B with old value 12, new value 13
T3 STARTS
T3 reads item A
T3 writes item A with old value 29, new value 30
T2 reads item A
T2 writes item A with old value 30, new value 31
T2 COMMITS
T1 reads item D
T1 writes item D with old value 44, new value 45***
T3 COMMITS
T1 COMMITS
[4-a] What serial schedule is this equivalent to? If none, then explain why.
[4-c] Is this schedule consistent with two phase locking? If your answer is yes,
then in column 2, insert into the schedule a minimal set of additional operations
that will make the schedule no longer consistent with two phase locking. Do not
introduce any new transactions. Make sure to show exactly where your new
operations should be inserted in the original schedule. If your answer is no, then
in column 2, remove from the schedule a minimal set of operations, so that the
revised schedule is consistent with two phase locking.
[4-d] Consider the version of the schedule that is consistent with two phase
locking (either the original one or your revised version, depending on your
answer to the previous part). Is that version consistent with strict two phase
locking? Why or why not?
4
[4-c] Now consider an undo log corresponding to the original schedule. Suppose
that a crash occurs right after the log record with asterisks next to it is written to
disk, and the recovery procedure is then run.
(i) What transactions get rolled back?
(ii) Does cascading rollback take place? Why or why not?
(iii) Which operations in the log get undone?
(iv) At the time of the crash, which of the five data write
operations are guaranteed to have taken place on disk?
(v) At the time of the crash, which of the five data write
operations are guaranteed to not have taken place on disk

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

Students also viewed these Databases questions