Ass4 - McGill, University of

advertisement
School of Computer Science, McGill University
COMP-421B Database Systems, Winter 2008
Written Assignment 4: Transactions & Indexing
Due: April 11, 2008
Exercise 1: For each of the following schedules:
a) T1: R(X), T2: R(X), T3: R(Y), T1: W(X), T2: R(Z), T2: R(Y), T2: W(Y), T1:
W(Z)
b) T1: R(X), T1: W(Y), T2: R(Y), T2: W(Z), T3: R(Z), T3: W(X)
c) T3: W(X), T1: R(X), T1: W(Y), T2: R(Y), T2: W(Z), T3: R(Z)
d) T1: R(X), T2: R(X), T1: W(Y), T2: W(Y), T1: R(Y), T2: R(Y), T2: W(Z), T1:
W(S)
e) T1: R(X), T2: R(X), T1: R(Y), T2: R(Y), T3: R(X), T4: R(Y), T1: W(X), T2:
W(Y)
Answer the following questions:
i.
Draw the precedence graph for the schedule?
ii.
Is the schedule conflict serializable? If so, what are all the equivalent serial
schedules.
iii.
Insert shared and exclusive locks, and insert unlock actions.
Exercise 2: Consider the following classes of schedules: serializable, recoverable, avoid
cascading aborts, and strict. For each of the following schedules, state which of the above
classes it belongs to. If you cannot decide whether a schedule belongs in a certain class
based on the listed actions, explain why not.
a) T1: R(X), T2: R(X), T1: W(X), T2: W(X)
b) T1: R(X), T2: W(X), T1: W(X), T2: Abort, T1: Commit
c) T2: R(X), T3: W(X), T3: Commit, T1: W(Y), T1: Commit, T2: R(Y), T2: W(Z),
T2: Commit
d) T1: R(X), T2: W(X), T2: Commit, T1: W(X), T1: Commit, T3: R(X), T3:
Commit
e) T1: R(X), T2: W(X), T1: W(X), T3: R(X), T1: Commit, T2: Commit, T3:
Commit
Exercise 3: Consider the following schedule. Initial values for data items A and B are
respectively 10 and 20.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
T1
Start
Read(A)
A=A+1
Write(A)
T2
T3
Start
Read(A)
Start
Write(A)
A=A+1
Write(A)
Read(B)
B=B+1
Write(B)
Commit
Read(B)
B=B+1
Write(B)
Commit
Read(B)
B=B+1
Write(B)
Commit
a) Now assume that the system crashes after step 20, what recovery action do you
suggest when the system is brought back up?
b) Is the schedule possible under two-phase locking protocol? (explain why/why not)
c) Is the schedule possible under tree locking protocol? (explain why/why not)
Exercise 4:
a) Construct a B+-tree for the following set of key values:
(2, 3, 5, 7, 11, 17, 19, 23, 29, 31)
assuming that the tree is initially empty, values are added in ascending order,
and the number of pointers will then fit in one node is 4.
b) For the B+-tree you constructed in (a), show the steps involved to find records
with a search-key value of 11.
c) For the B+-tree you constructed in (a), show the steps involved to find records
with a search-key value between 7 and 17, inclusive.
Download