Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Dbms S5

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

TRANSACTIONS AND CONCURRENCY CONTROL

Solutions
1. Consider three data items D1, D2 and D3 and D3 and the following execution schedule of
transactions T1, T2 and T3. In the diagram, R(D) and W(D) denotes the actions reading and
writing the data item D respectively.
T1 T2 T3
R(D3);
R(D2);
W(D2);
R(D2);
R(D3);
R(D1);
W(D1);
R(D1);
R(D2);
W(D2);
W(D1);

Which of the following statements are correct?

(a) The schedule is serializable as T2; T3; T1 (b) The schedule is serializable as T2; T1; T3
(c) The schedule is serializable as T3; T2; T1 (d) The schedule is not serializable

Solution: Option (d)

2. Consider the following transaction involving 2 bank accounts x and y.

read(x);
x:= x-50;
write(x);
read(y);
y:=y+50;
write(y);

The constraint that the sum of the accounts x and y should remain constant is that of:

(a) Atomicity (b) Consistency


(c) Isolation (d) Durability

1
Solution: Option (b)

The above constraint is maintained by consistency.

3. Consider the following partial schedule S involving 2 transactions T1 and T2. Only the read
and write operations have been shown. The read operation on data item P is denoted by r(P)
and write by w(P):

Transaction_id
Time
T1 T2
1 r(A)
2 w(A)
3 r(C)
4 w(C)
5 r(B)
6 w(B)
7 r(A)
8 Commit
9 r(B)

Suppose that the transaction T1 fails immediately after time instance 9. Which one of the
following statements is correct?

(a) T2 must be aborted and then both T1 and T2 must be restarted to ensure transaction
atomicity
(b) Schedule S is non-recoverable and cannot ensure transaction atomicity
(c) Only T2 must be aborted and then restarted to ensure transaction atomicity
(d) Schedule S is recoverable and can ensure atomicity and nothing else needs to be done

Solution: Option (b)

T2 reads value of ‘A’ which is written by T1 and T2 is committed before T1.

4. How many concurrent schedules can be formed with 3 transactions having 3, 2, 1 operations?

Solution: 60

3+2+1 !
Using the formula-→ =60
3!2!1!

2
COMMON DATA QUESTIONS

5. Consider the following schedules:

S1: W2(x), W1(x), R3(x), R1(x), W2(y), R3(y), R3(z), R2(x)


S2: R3(z), W2(x), W2(y), R1(x), R3(x), R2(z), R3(y), W1(x)
S3: R2(z), W2(x), W2(y), W1(x), R1(x), R3(x), R3(z), R3(y)

Which one of the above schedules are conflict equivalent?

(a) S1, S2 (b) S1, S3


(c) S2, S3 (d) None of these

Solution: Option (d)

6. Which of the schedules are serializable?

(a) S1, S2 (b) S1, S3


(c) S2, S3 (d) None of these

Solution: Option (c)

7. Consider the following schedules:

S1: r1(A); r3(A); w1(A); r2(A); w2(B); w3(B)


S2: r1(A); w1(a); r3(A); w1(B); r2(A); w3(B); r2(B)

Which one of the following is conflict serializable?

(a) S1 (b) S2
(c) S1, S2 (d) None of these

Solution: Option (b)

8. Which of the following is True for schedule S?

S: r1(a), r2(b), w2(a), w2(b),w3(a), r3(c), w3(b), r1(c), w4(b), w3(c), r4(a), r4(c), w4(c); commit1,
commit2, commit3, commit4

3
(a) S is conflict serializable with sequence <T1 T2 T3 T4>
(b) S is view serializable but not conflict serializable
(c) S is neither conflict serializable nor view serializable
(d) S is conflict serializable with <T2 T1 T3 T4>

Solution: Option (a)

9. The time stamp of 2 transactions T1 and T2 are 10 and are 10 and 15 respectively. Consider
the following with T1 and T2 operations.

S: R1(x), W1(x), R2(x), W2(x); R1(y), W1(y), R2(y), W2(y)

Which of the following is true?

(a) S holds in Basic time stamp protocol (b) S holds under Thomas Write rule
(c) Both A and B (d) None of these

Solution: Option (a)

10. Which problem among the following is encountered in the given schedule?

T1 T2
R(A)
R(B)
B=A
W(B)
R(A)
A= A+10
W(A)
Commit
R(A)
R(C)
C=A
W(C)

Solution: Option (d)

4
11. Consider the following scenarios:

T1 T2
R(A)
R(B)
R(C)
R(A)
R(B)
P:___
Q:___
R(C)

The possible values of P and Q allowed under Thomas Write Rule but not under basic time
stamp ordering protocol if TS(T2) > TS(T1)

(a) W(B), W(C) (b) W(A), W(A)


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

Solution: Option (b)

12. Consider the following tree and locking sequence:

I. Lock_X(A), lock_X(B), lock_X(D), unlock(D), lock_X(F), unlock(F), unlock(B),


unlock(A)
II. Lock_X(A), lock_X(E), lock_X(H), unlock(H), unlock(E), unlock(A)
III. Lock_X(B), lock_X(F), lock_X(E), unlock(F), unlock(E), unlock(B)

Which of the following is the valid locking sequence for true based protocol?

(a) II and III (b) I only


(c) I and III (d) II only

5
Solution: Option (c)

13. Consider the following schedule:

T1 T2
R(A)
A=A+10
R(B)
A=B+10
W(A)
R(B)
B=B+10
R(A)
B=A+10
W(B)
Commit
Commit

Which of the following transaction problems is present in the given schedule?

(a) Dirty Read (b) Lost update


(c) Unrepeatable read (d) Both (a) and (b)

Solution: Option (a)

14. The precedence graph of a schedule with 3 transactions T1, T2, T3 is:

The possible schedule is:


(a) r1(A); w2(A); w1(A); w3(A) (b) r1(A); w2(A); w3(A); w1(A)
(c) r1(A); w3(A); w2(A); w1(A) (d) None of these

Solution: Option (a)

6
7

You might also like