Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

TRANSACTIONS AND CONCURRENCY CONTROL

1. Consider the following schedule:

S1: R1(A); R1(C); R2(B); W2(B); R3(B); R1(A); R3(C); W3(C); W1(A)
S2: R2(A); R1(C); R2(B); R3(B); W2(B); R1(A); R3(C); W3(C); W1(A)

Which of the above schedules are conflict serializable?

(a) S1 only (b) S2 only


(c) Both S1 and S2 only (d) Neither S1 nor S2

2. Consider the following schedule:


S: r2(A), r1(B), w2(A), r2(B), r3(A), w1(B), w3(A), w2(B)

How many minimum number of moves (where a move consisting of changing the position of
one of the operations) are required to convert S into a conflict serializable schedule?

(a) 1 (b) 2
(b) 3 (d) 4

3. Consider 2 schedules S1 and S2 with same set of transactions and precedence graph of S1 is
same as precedence graph of S2. Which of the following statement is True?

(a) Both S1 and S2 are conflict equal and conflict serializable schedule
(b) Both S1 and S2 are conflict equal but may not conflict serializable schedule
(c) Both S1 and S2 are conflict equal but may not equal schedules
(d) Both S1 and S2 are conflict equal and but may not view equivalent

4. Which of the following schedules are recoverable?

S1: r1(x), r2(z), r1(z), r3(x), r3(y), w1(x), C1, w3(y), C3, r2(y), w2(y), w2(z), C2
S2: r1(x), r2(z), r1(z), r3(x), r3(y), w1(x), w3(y), r2(y), w2(z), w2(y), C1, C2, C3
S3: r1(x), r2(z), r3(x), r1(z), r2(y), r3(y), w1(x), C1, w2(z), w3(y), w2(y), C3, C2

(a) Only S1 (b) Only S1, S3


(c) Only S2, S3 (d) All S1, S2, S3

1
5. For the given schedule which of the following statement is true?
S: R4(A), R2(A), R3(A), W1(B), W2(C), R4(B), W2(B)

(a) The schedule cannot be serialized


(b) The schedule is equivalent to T3, T4, T1, T2
(c) The schedule is equivalent to T1, T4, T3, T2
(d) The schedule is equivalent to T2, T3, T1, T4

6. Consider the following schedule:


S: r1(A), r2(B), X, w1(C), w2(A)

How many operations (Read/ Write) can be placed in ‘X’ to make ‘S’, not conflict
serializable?

7. Consider the following schedule:


S: r1(A), r2(A), r3(B), w1(A), r2(C), r2(B), w2(B), w1(C)

How many conflict equal serial schedules are possible with the above schedule?

LINKED QUESTIONS: Q.8 AND Q.9

Based on a simple relation TA(SID, CID, Stipend) stores TA assignments and stipends. TA’s
are identified by their student ID’s (SID’s). Consider the following, if transaction executed by
2 different clients at approximately the same time.

T1 T2

Step1: UPDATE TA UPDATE TA


SET Stipend= Stipend + 200 SET Stipend= 200
where CID= ‘CS145’ where Stipend > 2000
COMMIT
Step2: UPDATE TA
SET Stipend= Stipend + 200
where CID= ‘CS145’;
COMMIT

Before either transaction starts, there is a tuple (987, ‘CS145’, 1900) in TA.

2
8. Suppose T1 executes with isolation level READ COMMITTED and T2 executes with isolation
level READ UNCOMMITTED. Which one of the following figures cannot be a possible final
stipend value for TA987?

(a) 2000 (b) 2200


(c) 2300 (d) None of these

9. Now, suppose instead that T1 executes with isolation level. Repeatable Read and T2 executes
with isolation level Read Committed. Which one of the following figures cannot be a possible
value for TA987?

(a) 2000 (b) 2200


(c) 2300 (d) None of these

COMMON DATA QUESTIONS

10. Consider the following schedules:

S1: R1(A), W1(A), R2(B), R1(B), W1(B), W2(A), R2(C), R1(C)


S2: R2(B), W2(A), R1(A), W1(A), R1(B), W1(B), R2(C), R1(C)
S3: R1(A), W1(A), R2(B), W2(A), R1(B), W1(B), R1(C), R2(C)
S4: R2(B), R1(A), W2(A), W1(A), R1(B), W1(B), R2(C), R1(C)

Which of the above schedule(s) is/are conflict serializable?


(a) S1 and S2 only (b) S2 only
(c) S1 only (d) None of these

11. Which of the following is TRUE with regards to the correct answer for the above question?

(a) S1 is conflict serializable to T1, T2 (b) S2 is conflict serializable to T2, T1


(c) Both (A) and (B) (d) None of these

12. Which among the following 2-phase locking protocols is a deadlock free?

(a) Basic 2PL (b) Strict 2PL


(c) Rigorous 2PL (d) Conservative 2PL

3
Given below are some transaction schedules that involve three transactions:
T1-T2-T3

Schedule 1:
T2: Rx, T2: Ry, T1: Wx, T3: Wy, T3: Wz, T1: Rz, T2: Wy

Schedule 2:
T2: Rx, T2: Wy, T3: Ry, T3: Wx, T1: Wy, T3: Rx, T1: Ry, T2: Wy

Schedule 3:
T1: Rx, T2: Ry, T3: Wy, T2: Rz, T3: Rz, T1: Wz, T1: Wy, T2: Wy

Schedule 4:
T1: Rx, T3: Wy, T2: Rz, T3: Rz, T1: Wy, T2: Wx, T1: Ry, T2: Wz

13. Which of the given schedule is conflict serializable?

(a) Schedule 1 (b) Schedule 2


(c) Schedule 3 (d) Schedule 4

14. For the conflict serializable schedule found in the previous question, the equivalent serial
schedule possible:

(a) T3- T1- T2 (b) T2- T1- T3


(c) T3- T2- T1 (d) None of these

15. Which of the following is True about the given schedule ‘S’?

T1 T2
R(A)
A=A+100
R(A)
A=A*2
W(A)
W(A)
R(B)
B= B/2
W(B)
R(B)
B= B-100
W(B)

4
(a) It is conflict serializable
(b) It is view serializable but not conflict serializable
(c) It is conflict serializable but not view serializable
(d) It is not serializable

16. Which among the following schedules is an irrecoverable schedule?

17. Suppose a schedule with 2 transactions T1 and T2:

T1 T2
Read(A)
Write(A)
Read(A)
Commit
Read(A)
Abort

The above schedule is:

(a) Cascadeless schedule (b) Recoverable schedule


(c) Irrecoverable schedule (d) None of these

5
18. There are 2 transactions, T1 with 2 instructions and T2 with 5 instructions. Find the number of
serial and concurrent schedules respectively.

(a) 2, 2 (b) 21, 21


(c) 2, 21 (d) 21, 2

19. Which of the following statements are true about recoverable and cascadeless schedules?

(P) All cascadeless schedules are also recoverable


(Q) All recoverable schedules are also cascadeless schedules
(R) All strict schedules are cascadeless and recoverable
(S) All cascadeless and recoverable schedules are strict schedule

(a) P and R are correct (b) P and S are correct


(c) P, R and S are correct (d) P, Q and S are correct

20. Which of the following is false?

(a) All the schedules which are allowed under basic time stamp ordering protocols are also
allowed under Thomas Write Rule
(b) Schedule which are allowed under Thomas write rule are also allowed under
multiversion time stamp ordering protocol
(c) All the schedules which are not allowed under Thomas write rule are also not allowed
under multiversion time stamp ordering protocol
(d) None of these

You might also like