

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















This exam is open book and notes. You can use a calculator and your laptop to access course notes and videos (but not to communicate with other people or to browse the Internet). You have 180 minutes to complete the exam.
Best of luck!!!
Print your name:
The Honor Code is an undertaking of the students, individually and collectively:
The faculty on its part manifests its confidence in the honor of its students by refraining from proctoring examinations and from taking unusual and unreasonable precautions to prevent the forms of dishonesty mentioned above. The faculty will also avoid, as far as practicable, academic procedures that create temptations to violate the Honor Code.
While the faculty alone has the right and obligation to set academic requirements, the students and faculty will work together to establish optimal conditions for honorable academic work.
I acknowledge and accept the Honor Code.
Signed:
Problem Points Maximum 1 10 2 10 3 10 4 10 5 10 6 10 7 20 Total 80 Please note: Problem 7 (true/false) is worth 20 points.
Consider a database with two elements, X and Y. The initial values of X and Y are both 0. We consider three transactions U, V and W that modify these elements concurrently:
While the transactions execute, the database system crashes. We consider three recovery mechanisms in turn below; your task is to first complete the missing parts of the log and then answer the following questions:
(a) Using pure undo logging:
(i) Please complete the undo log by providing in the appropriate values for the log below:
Line 6:
Line 10:
(ii) If the database crashes immediately after writing the above log entries, then subse- quently performs recovery, which of the following statements is true: A. After a successful recovery, the state of Y is 0.
(b) Using pure redo logging:
(i) Line 7:
Line 9:
(ii) If the database crashes immediately after writing the above log entries, then subse- quently performs recovery, which of the following statements is true: A. After a successful recovery, the state of X is 100. B. At the time of crash, the state of X (on disk) must be 42. C. At the time of crash, the state of Y (on disk) must be 20. D. After a successful recovery, the state of Z is 0.
True statement (one of A, B, C, or D):
(c) Using undo-redo logging, with log format (txn, item, before-val, after-val):
(i) Please complete the undo-redo log by providing in the appropriate values for the log below:
Line 9:
Line 13:
(ii) If the database crashes immediately after writing the above log entries, which of the following statements is true: A. During recovery, the log entry in line 4 will be redone. B. During recovery, the log entry in line 7 will be ignored. C. During recovery, the log entry in line 9 will be ignored. D. During recovery, the log entry in line 13 will be undone.
True statement (one of A, B, C, or D):
(c) R 3 (B)R 2 (A)R 1 (A)R 2 (C)W 3 (A)W 2 (B)W 1 (C)
(d) W 1 (A)W 2 (B)W 1 (B)W 2 (A)
Solutions:
(a) R 1 (A)W 2 (B)R 2 (A)W 1 (B)W 3 (B)W 1 (C)R 3 (B)W 1 (A)
T 1 T 2
Conflict serializable, equivalent to T 2 T 1 T 3
(b) W 2 (C)R 1 (A)W 3 (B)R 1 (C)R 3 (B)R 3 (A)W 2 (B)W 1 (B)
T 1 T 2
Conflict serializable, equivalent to T 3 T 2 T 1
(c) R 3 (B)R 2 (A)R 1 (A)R 2 (C)W 3 (A)W 2 (B)W 1 (C)
T 1 T 2
Not conflict serializable due to R 3 (B) before W 2 (B) and R 2 (A) before W 3 (A).
(d) W 1 (A)W 2 (B)W 1 (B)W 2 (A)
T 1 T 2
Not conflict serializable due to W 1 (A) before W 2 (A) and W 2 (B) before W 1 (B).
The following 5 transactions execute under a validation concurrency control protocol:
Consider the following sequence of events:
State which transactions validate successfully and which do not. If a transaction successfully validates, write “YES.” If not, write ‘NO” and state the conflict by stating the transactions that conflict, and which item(s) they conflict on (e.g., “T 1 and T 2 have a read-write conflict on F”).
(a) Does T 1 validate successfully? If not, state the conflict as instructed above. No. There is a read-write conflict on B between T 1 and T 2.
(b) Does T 2 validate successfully? If not, state the conflict as instructed above. Yes.
(c) Does T 3 validate successfully? If not, state the conflict as instructed above. No. There is a read-write conflict on A between T 3 and T 2.
(d) Does T 4 validate successfully? If not, state the conflict as instructed above. Yes.
(e) Does T 5 validate successfully? If not, state the conflict as instructed above. No. There is a write-write conflict on D between T 4 and T 5.
SIX(R),IX(A),IS(B),IX(t1),IS(t3),X(t1.E),S(t3.H) locks at the same level can be switched
(b) Consider the following four schedules, each with two transactions, U and V, executing under the multi-granularity locking system and database as above. Circle the schedules that can be be achieved under strict 2-phase locking. Below, wU (A) refers to write of table A by transaction U.
(i) rU (t 1 .E), wV (A), commit(U ), commit(V ) (ii) rV (A), wU (t3), rU (t1), commit(U ), commit(V ) (iii) wV (t1), rU (A), rV (A), commit(U ), commit(V ) (iv) wU (t1), rU (A), wV (t3), commit(U ), commit(V )
ii and iv should be circled.
(c) Consider the following index consisting of nodes N 1 through N 10 :
N
N
N
N
N5 N6 N
N
N9 N
What is the sequence of lock and unlock operations required to lock node 10? As above, provide your answer in the spaces below, with one lock or unlock operation per space pro- ceeding left to right (you need not use all the spaces provided). Only depict lock or unlock operations (no intention locks). For example: L(N 5 )U (N 5 )L(N 1 )U (N 1 )
hint: the above example is not correct.
(a) Simulation when wait-die deadlock prevention is used:
Step T 1 T 2 T 3 1 L(B) L(A) L(C)
2 Wait Wait Die
3 L(C) Die Die
5 U(B) Wait Die
6 L(C) Die
7 U(A) Die
8 U(C) Die
(b) Simulation when wound-wait deadlock prevention is used:
Step T 1 T 2 T 3 1 L(B) L(A) L(C)
2 L(C) Wait Die
3 U(C) L(C) Wait
4 U(B) U(A) Wait
(a) Query Processing I/Os: Consider performing a natural join operation on two relations R(A, B) and S(B, C). Assume that R contains 36000 records stored contiguously on 1800 disk blocks (i.e., B(R) = 1800; 20 tuples per block), and that S contains 1000 records stored non-contiguously and that each block of memory and disk can store 20 tuples of S.
(i) Suppose we have just two blocks of memory. Ignoring output I/Os, what is the minimum number of I/Os required to perform the natural join via a iteration join if use our two blocks of memory to store one block each of R and S in memory at a time?:
Since S is not stored contiguously, we should hold S in memory to avoid I/Os, then do multiple passes over R. We will read in S one memory block at a time, then join with R. We have 1000 /20 = 50 passes of R. Therefore, we have 1000 I/Os to read in S, and 20 ∗ 1800 I/Os to join with S. 37 , 000 I/Os total.
(ii) Suppose we have just enough memory to allow a two-pass hash join (not hybrid hash join!). Ignoring output I/Os, Using a two-pass hash join (as described in class notes 7, slides 61-64), what is the total number of I/Os required to perform the natural join via a hash join?:
Cost to read and write R = 1800 ∗ 2 = 3600. Cost to read and write S = 1000 + 50 =
(b) Cardinality Estimation: Consider relations M (A, B), N (C, D), each containing 500 records.
(i) What is the expected number of records in [M ./ N ]?
(ii) Given a selection predicate B = 2 with expected selectivity 0. 01 (i.e., 1 in 100 records will match the predicate). What is the expected number of records in [σB=2M ./ N ]?
(iii) Given a selection predicate B = 2 with expected selectivity 0. 01. What is the expected number of records in σB=2[M ./ N ]? 0. 01 ∗ 500 ∗ 500 = 2500
(iv) Given a selection predicate B = 2 with expected selectivity 0. 01 and a selection pred- icate C = 4 with expected selectivity 0. 1. What is the expected number of records in [σB=2M ./ σC=4N ]? 0. 01 ∗ 500 ∗ 500 = 250
(c) Storage Costs: Consider relation D(A, B, C) such that column A contains a 8 byte string, column B contains a 4 -byte floating point number, and column C contains a binary blob of up to 2048 bytes represented by a 2-byte header followed by the data. If we store D on a disk with block size 512 :
(i) What is the minimum number of blocks required to store 1000 records of D? (8 + 4 +
(i) Ignoring the cost of additional headers required to mark records that span multiple blocks, what is the maximum number of blocks required to store 1000 records of D? (8 + 4 + 2 + 2048) ∗ 1000 / 512 = 4028 blocks