Fundamentals of Database Systems Assignment: 6 25th Aug, 2015 Instructions 1. This question paper contains 15 questions in 6 pages. Q1: In the log based recovery scheme, which of the following statement is false? A. The database records are modified only after their corresponding log records are written onto the disk B. The database records and their corresponding log records can be updated onto the disk in any order C. Log records are periodically updated onto the disk D. During recovery using a checkpoint, transactions are not allowed to perform update operations Answer: B is false, because log records are always written onto disk before their corresponding database records are written. Q2: Assume a deferred database modification scheme. Consider the following example of redo log for two transactions. 1. (Start, T1); 2. (Write, T1, Q, 100); 3. (Commit, T1); 4. (Start, T2); 5. (Write, T2, P, 55); 6. (Commit, T2); Consider the following two cases: Case-1: The schedule crashes after Step 5 and before Step 6, and the recovery completes successfully. Case-2: The schedule crashes after Step 5 and before Step 6, and the recovery process starts. During recovery process, the schedule crashes after Step 2 and before Step 3. Which of the following actions must be done for the two cases? A. Case-1: T1: Redo, T2: No action; Case-2: T1: Redo, T2: No action B. Case-1: T1: Redo, T2: Redo; Case-2: T1: Redo, T2; No action C. Case-1: T1: Redo, T2: Redo; Case-2: T1; Redo, T2: Redo D. Case-1: T1: Redo, T2: No action; Case-2: T1: No action, T2: No action 1
Answer: In case of deferred database modification, writes are reflected on the database only after commit log has been written. Hence, for consistent state in both cases, T1 must do the redo operation. On the other hand, no action needs to be taken for T2, because the write operation of T2 has not been reflected on the database. During the second recovery, since it is not guaranteed that the first write has gone through or not, T1 needs to write once more. Q3: Assume an immediate database modification scheme. Consider the following log consisting transactions T1, T2, and T3: 1. (Start, T1); 2. (Write, T1, P, 500, 600); 3. (Write, T1, Q, 400, 500); 4. (Commit, T1); 5. (Start, T2); 6. (Write, T2, P, 600, 550); 7. (Write, T2, Q, 500, 450); 8. (Commit, T2); 9. (Start, T3); 10. (Write, T3, P, 550, 600); 11. (Write, T3, Q, 450, 500); 12. (Commit, T3); Which of the following statement is false? A. If the schedule crashes just after Step 3, then Undo(T1) is performed. B. If the schedule crashes just after Step 11, then after complete recovery process the value of P=550 and Q=450 C. If the schedule crashes just after Step 7, then recovery operations are performed according to the order: Redo(T1), Undo(T2) D. If the schedule crashes just after Step 6, then before the recovery process is started, the system can be in inconsistent state with values of P=550, Q=400 Answer: C is false, because for the recovery algorithm, undo operations are done first, and then redo operations. Q4: For the given schedule, which of the following statement(s) is (are) true? S : r 1 (x), w 1 (x), r 2 (x), r 1 (y), w 1 (y), w 2 (x), r 2 (y), c 1, c 2 ; I: S is recoverable. II: If the order of w 1 (x) and w 2 (x) are interchanged, then S will be a non-recoverable schedule. A. Only I B. Only II C. Both I and II D. None of the above Page 2 of 6
Answer: T 2 reads y after T 1 writes it and T 1 commits before T 2 ; thus, S is recoverable. Since T 1 does not read any item after T 2 writes, if T 2 aborts, T 1 will remain intact. Q5: Given the schedule S, which of the following is true? S : r 1 (x), r 3 (y), r 3 (x), w 1 (x), c 1, w 2 (y), r 2 (x), w 3 (y), c 2, c 3 A. S is not recoverable. B. S is recoverable but not cascadeless. C. S is cascadeless but not strict. D. S is strict. Answer: T 2 reads x after the last transaction that writes x, i.e., T 1, has commited. Hence, S is cascadeless. However, since T 2 writes y before T 3, which has most recently written y, has committed, S is not strict. Q6: Consider the following schedule. S : r 1 (x); w 1 (y); r 2 (x); w 2 (y); r 3 (x); w 3 (y); How many schedules of the six actions in S are conflict-equivalent to S? A. 12 B. 15 C. 24 D. 30 Answer: The three writes have to appear in the order shown, so let us start with the sequence w1(y), w2(y), w3(y), and see where the other three actions could fit in. First, r1(x) must appear before w1(y) because we cannot reorder actions of a transaction. Thus, there is only one choice so far: r1(x), w1(y), w2(y), w3(y). Now, r2(x) can appear in any of the points before w2(y), so there are three choices of where to put r2(x). Finally, regardless of where we put r2(x), there are five choices of where to put r3(x) anywhere ahead of w3(y). Thus, there are 3 x 5 = 15 possible schedules. Q7: Given the following two schedules: S 1 : r 1 (x), r 2 (x), w 2 (x), r 3 (x), w 1 (x), w 2 (y), r 3 (y), w 3 (x) S 2 : r 2 (x), r 1 (x), w 1 (x), w 2 (x), w 2 (y), r 3 (x), w 3 (x), r 3 (y) Which of the following statements are true? I: S1 and S2 are view equivalent. II: S1 performs blind write but S2 does not. A. Only I B. Only II C. Both I and II Page 3 of 6
D. None of them Answer: S1 and S2 are view equivalent since they satisfy all the 3 conditions of view equivalence. S1 and S2 both performs blind write, T 2 writes y without reading it in both S1 and S2. Q8: Consider the two schedules: S 1 : r 1 (x), r 2 (x), w 2 (x), r 3 (x), w 1 (x), w 2 (y), r 3 (y), c 2, w 3 (x), c 1, c 3 S 2 : r 2 (x), r 1 (x), w 1 (x), w 2 (x), w 2 (y), r 3 (x), w 3 (x), r 3 (y), c 1, c 3, c 2 Which of the schedules is recoverable? A. Only S1 B. Only S2 C. Both S1 and S2 D. None of them Answer: S2 is non recoverable because T 3 reads x after T 2 writes but T 3 commits before T 2. Q9: Which of the following statements is false? A. The problem of testing view serializability is NP-complete. B. Serializability ensures correctness of a schedule. C. A conflict serializable schedule is always equivalent to one and only one single serial schedule. D. Every cascadeless schedule is recoverable. Answer: For a conflict serializable schedule, the linear ordering of transactions corresponds to topological sorting of the serialization graph. Since there can be multiple such orderings, multiple equivalent serial schedules may exist. Q10: For the schedule S given below, if transaction T 1 aborts after the last operation of schedule S, then which of the following statements will be true? S : r 1 (x), r 2 (z), w 1 (x), r 3 (x), r 2 (y), w 2 (y), w 3 (x), r 3 (y), r 2 (x) A. Only T 3 will be rolled back. B. First T 2 will be rolled back followed by T 3 rollback. C. First T 3 will be rolled back followed by T 2 rollback. D. There will be no cascading rollbacks. Answer: T 3 reads item x after the T 1 writes x. Thus, first T 3 will be rolled back followed by T 2 because later T 2 reads item x after T 2 writes it. Q11: S : r 1 (x), r 2 (z), w 1 (x), r 3 (x), r 2 (y), w 2 (y), w 3 (x), r 3 (y), r 2 (x) For the schedule S given above, two orderings of commit operations are specified. I: c 1, c 3, c 2 II: c 1, c 2, c 3 Which of these ordering ensures recoverabilty of schedule S? Page 4 of 6
A. Only I B. Both I and II C. Only II D. None of these. Answer: Both the orders are incorrect because T 3 reads item y after T 2 writes it and T 2 reads item x after T 3 writes x. Q12: Which of the following statements is false? A. Blind writes appear in every view-serializable schedule that is not conflict serializable. B. In serialization graph, an edge between two nodes exists if and only if the pair of transactions corresponding to the nodes have conflicting operations. C. Every strict schedule is recoverable. D. Every view serializable schedule is recoverable. Answer: Statement D since they are independent. Q13: Consider the following schedule: S : r 1 (y), r 2 (x), r 2 (y), r 3 (y), w 2 (x), w 1 (y), w 3 (x), r 1 (x) Which of the following statements is true about the schedule S? A. S is conflict serializable but not view serializable B. S is neither conflict serializable nor view serializable C. S is both conflict serializable as well as view serializable D. S is view serializable but not conflict serializable Answer: It is conflict equivalent to S 2, S 3, S 1. Q14: Consider the following schedule: S : r 1 (y), r 2 (z), w 1 (y), w 1 (z), r 2 (x), w 2 (x), r 2 (y), w 2 (y), r 1 (x), c 1, c 2 Which of the following is true about S? A. S is cascadeless B. S is not cascadeless, but recoverable C. S is not recoverable, but changing the order of commits to c 2, c 1 makes the schedule recoverable D. S is not recoverable, and changing the order of commits to c 2, c 1 does not make the schedule recoverable Answer: r 2 (y) is after w 1 (y) and r 1 (x) is after w 2 (x), so the schedule remains non-recoverable even after changing the order of commits. Q15: Consider the following schedule: S : r 1 (x), w 1 (x), r 1 (y), c 1, w 2 (x), c 2, r 3 (y), r 3 (x), c 3 Which of the following is true about the schedule S? Page 5 of 6
A. S is not cascadeless but recoverable B. S is not strict but cascadeless C. S is strict but not serial D. S is serial Answer: S is serial since the transactions take place one after another. Page 6 of 6