Transaction · Databases
38 questions · asked in 20 of 27 years (2000–2026)
MCQ 32 · MSQ 5 · NAT 11-mark 19 · 2-mark 19
Questions 26–30 of 38
T1 :read (P);
read (Q);
if P = 0 then Q := Q + 1 ;
write (Q).
T2 : read (Q);
read (P);
if Q = 0 then P := P + 1 ;
write (P). Any non-serial interleaving of T1 and T2 for concurrent execution leads toAnswer: (B)
- Suppose comes before . is the last operation of T2 and is the first operation of T1, so all of T2 runs before all of T1. That is a serial schedule, which is not allowed. So comes before , which gives the edge .
- Suppose comes before . is the last operation of T1 and is the first operation of T2, so the schedule is again serial. So comes before , which gives the edge .
The two edges make a cycle in the precedence graph, so every non-serial interleaving is not conflict serializable. Option (C) says the opposite. Option (D) is wrong because a precedence graph can be drawn for any schedule.
Answer: (B)
Which one of the schedules below is the correct serialization of the above?
Answer: (A)
- T1 does R(X) and W(X) before T3 does W(X), so
- T1 does W(X) before T2 does R(X), so
- T3 does R(Y) before T2 does W(Y), so
- T3 does W(X) before T2 does R(X) and W(X), so
The graph has no cycle, and the only order that respects all edges is .
Answer: (A)
I. 2-phase locking
II. Time-stamp ordering
Answer: (B)
- 2PL gives conflict serializability, but deadlock can happen.
- Timestamp ordering is serializable in the order of the timestamps. It never makes transactions wait in a cycle, because it aborts them instead so it is free from deadlock.
Answer: II only
Which of the above schedules are conflict-serializable?
Answer: (B)
- S1: gives . also gives . But gives . Cycle, so not conflict serializable.
- S2: , and all give . This is the only edge, so S2 is conflict serializable.
- S3: , and all give . This is the only edge, so S3 is conflict serializable.
- S4: and give , but gives . Cycle, so not conflict serializable.
So S2 and S3 are conflict serializable.
Answer: (B)
[Notation: In the following NYO represents the action Y (R for read, W for write) performed by transaction N on object O.]
Which of the following statements is TRUE?
Answer: (D)
Two schedules are conflict equivalent if we can get one from the other by swapping non-conflicting operations.
S1Here, we can swap R(C) and W(B), since they are a non-conflicting pair (as they work on different data items).
After the swap, the schedule becomes
S2 Here, we can move R(C) to after the T2 operations R(A), W(A) and W(B), since each of them forms a non-conflicting pair with R(C) (as they work on different data items).
Also, we can move W(C) so it runs before all the T1 operations, as each T1 operation forms a non-conflicting pair with W(C) (since they work on different data items).
After the swaps, the schedule becomes
S3Here, we can't swap the operations to make it because of the conflicting pair W(A) and W(A).
Option S1 is conflict equivalent to S2, but not to S3 is the correct answer.
Keep practising