Solution
Solution
02 May 2022
Total marks: 50
Question 1: Transactions
Consider schedules H1 and H2 given below:
H1 = r1 (x),r2 (z),r1 (z),r3 (x),r3 (y),w1 (x),w3 (y),r2 (y),w2 (z),w2 (y)
H2 = r1 (x),r2 (z),r3 (x),r1 (z),r2 (y),r3 (y),w1 (x),w2 (z),w3 (y),w2 (y)
Which among H1 or H2 is/are serializable? Explain by showing the precedence graph. In case of
serializable schedule, give the equivalent serializability order. [10 (4+4+2) Points]
Solution: H1 is serializable and the serialization order is T3 → T1 → T2. Since there is a cycle in the graph, H2
is not serializable. The precendence graph for H1 (left) and H2 (right) is given below:
Question 2: Hashing
Consider the following extendible hash index.
Three additional keys are inserted: 4*, 21* and 25*. (*) represents key. Having inserted the above three
keys, what is the minimum number of delete operations needed for the global depth to decrease?
Show all the details that led to the answer. (Hint: A bucket is merged with its split image if and
only if it becomes empty.) [10 points]‘
Solution: The index after inserting 4*, 21* and 25* looks like the following figure:
We can delete 5* and 21* from Bucket B2 to merged with its split image. Thus, minimum deletions required
are: 2.
1
Question 3: Recovery Systems
Consider the following log information that involves three transactions. Assume that the immediate update protocol
with check-pointing is used for crash recovery. And note that the log file does not necessarily record all operations
of a transaction.
Is the schedule, as shown in the log, recoverable? Why or why not? Does the schedule requires
rolling cascades after the crash? Why or why not? [10 (2+3+2+3) Points]
Solution: The schedule is not recoverable because T2 reads D whose value was written by T3 but T2 commits
before T3 commits. The rolling cascades are not going to work as T2 is already committed.
A → BC
CD → E
B→D
E→A
Product has 20,000 tuples, and each record is 20 bytes long. Company has 1,000 tuples, and each record is 25
bytes long. Each block can hold 5,000 bytes. The memory buffer has 102 vacant blocks. Assume that there are
500 distinct values for the attribute Location and that its distribution is uniform. Consider the following SQL query:
2
WHERE Product.PID = Company.PID
AND Location = “Madison” ;
Compute the total I/O cost (in terms of block transfers) and briefly explain each component of
the total cost. Ignore the cost of writing the output to disk. [10 points]
Solution: The number of blocks for Product is (20,000*20)/5,000=80, and for Company is (1, 000*25)/5,000=5.
Thus, both tables easily fit together in the buffer pool. Thus, a simple physical plan is to first compute the join.
Any join algorithm can be used; the I/O cost is just one read of each table, i.e., 80+5=85. After the join, we simply
pipeline the result to an in-memory selection on Location and then an in-memory projection without duplicate
elimination. Thus, we have no more I/O costs.