Transaction & Concurrency Control DPP 03 (Of Lec 08) 2
Transaction & Concurrency Control DPP 03 (Of Lec 08) 2
[NAT] [MCQ]
1. Consider the following schedule 6. The goal of concurrency control on database system is
S: w1(X); w1(Y); r2(X); w2(Y); r3(X); w3(Y) to
How many schedules are conflict equivalent to given (a) Only allow concurrent execution of transaction
schedule (S) _________? that correspond to serial execution of some of the
transactions.
[NAT] (b) Allow only transactions that don’t access common
relationship to run concurrently.
2. Consider the following schedule
(c) Execute transactions serially.
S = r1(P); r3(S); w1(Q); r2(Q) r4(Q), w2(R)
(d) None of the above.
r5(R); w4(T); r5(T); w5(Q)
How many serial schedules conflict equal to
schedules(S)? ________. [MCQ]
7. What problem can occur when a DBMS executes
multiple transactions concurrently?
[NAT]
(a) Lost update problem.
3. Consider the following schedule
(b) Dirty read problem.
S = r1(P); r3(S); w1(Q); r2(Q) r4(Q), w2(R);
(c) Incorrect summary problem.
r5(R); w4(T); r5(T); w5(Q)
(d) All of the above.
How many serial schedules view equal to
schedule(S)__________?
[MCQ]
8. Consider the following statements
[MCQ]
S1: Every view serializable schedule is conflict
4. Consider the following transactions
serializable.
T1: r1(P); w1(P); r1(Q); w1(Q)
S2: Some view serializable schedules are conflict
T2: r2(P); r2(Q)
serializable.
T3: w3(P); w3(Q)
(a) Only S1 is true.
How many concurrent schedules between T1, T2 and T3
(b) Only S2 is true
transactions _________?
(c) Both S1 & S2 are true
(a) 400
(s) Neither S1 nor S2 is true
(b) 410
(c) 420
[MCQ]
(d) None
9. Consider the following schedule involving two
transactions
[NAT]
S1: r1(A); r2(A); w2(A); r3(A); w1(A); w2(B); r3(B),
5. How many views equivalent serial schedules are
c2, w3(A); c1, c3
possible for the given schedules below _________
S: w1(P) r2(P) w3(P) r4(P)w5(P) r6(P) S2: r2(A); r1(A); w1(A); w2(A); w2(A); r3(A); w3(A),
r2(B); c1, c3; c2
2
Answer Key
1. (8) 7. (d)
2. (10) 8. (b)
3. (10) 9. (a)
4. (c) 10. (d)
5. (2) 11. (a)
6. (a)
4
r3(X)
-
4 ways
T1 → T2
Total 8 conflict equal schedules to the given schedule.
T1 → T4
T2 → T5
2. (10)
T4 → T5
Constructing the precedence graph
view equal serial orders
T1 T2 T5
5 ways
5
4. (c) S2:
8! T1 T2 T3
= 420 r2(A)
4! 2! 2!
r1(A)
w1(A)
5. (2) w2(A)
S: w1(P)r2(P) w3(P)r4(P) w5(P)r6(P) w2(B)
r3(A)
w3(A)
Final write r3(B)
• Can exchange c1
• without violation view equal conditions c3
View equal serial schedules are c2
T1 T2 T3 T4 T5 T6 Here T3 reads the changes of T2 but T3 commits
T3 T4 T1 T2 T5 T6 before T2. So it is not recoverable schedule.
Hence, correct option is (a).
[NAT] [MCQ]
1. Two operations are called conflicting operations, if 4. Suppose many concurrent transactions are made to
they satisfy which of the below conditions: run over the same data set and the 2nd transaction
I: They work on same data item. updates the database before the 1st transaction is
II: Both the operations belong to different finished or completed its execution then which one
transactions. among the following property is violated and the
III: There exists at most one write operation. database is no longer consistent.
The number of conditions satisfied for conflicting (a) Durability (b) Isolation
operations is/are ________.
(c) Atomicity (d) Consistency
[MCQ]
[MSQ]
5. Consider the following T1 and T2 transactions:
2. Consider the following schedule S:
P = 0 and Q = 0;
T1 T2 T3
T1: Read(P);
R(x) Read(Q);
W(x) If P = 0 then Q = Q + 10;
R(x) write (B);
W(x) T2: Read(Q);
W(x) Read(P);
Choose the correct statements from the following for If P = 0 then P = P + 15;
above schedule S. write (P);
(a) S is a conflict serializable schedule. The non-serial interleaving of T1 and T2 for
(b) S is a view serializable schedule. concurrent execution leads to
(c) S is a serializable schedule. (a) Serializable Schedule
(d) None of the above. (b) Schedule which is not conflict serializable
schedule.
[NAT] (c) A conflict serializable.
3. For the given schedule S below, the number of (d) None of these.
conflict pairs is/are: [MCQ]
S: 6. Consider the following statements:
T1 T2 T3 S1: If a schedule is view serializable then it may not
R(x) be conflict serializable.
R(x)
S2: If a schedule is conflict serializable then it is also
R(x)
view serializable schedule.
W(y)
(a) Only S1 is true
W(y)
W(y) (b) Only S2 is true
(c) Both S1 & S2 are true
(c) Neither S1 nor S2 is true
2
Answer Key
1. (2) 5. (b)
2. (b, c) 6. (c)
3. (3) 7. (c)
4. (b) 8. (10)
4
6. (c)
S1(true): If a schedule is view serializable then it
may not be conflict serializable.
Cycle exists in the precedence graph; therefore,
the schedule is not conflict serializable. S2(true): If a schedule is conflict serializable then it
is also view serializable schedule
II: Checking for view serializability.
Since there is a cycle in the precedence graph
and also there exists a blind write by 7. (c)
transaction T2 on data item x, so it may or may • T1 and T2 are committed. So, T1 and T2 will
not be view serializable. perform Redo.
Case 1: Initial read on data item x: T1 → T3 • T3 is not committed. So, T3 will Perform Undo.
Case 2: Updated write on data item x: T2 → T3 Hence, option (c) is correct.
Case 3: Final write on data item x: T3
By above three cases we can say the serial
order:
T1 → T2 → T3 8. (10)
Thus, the schedule S is view serializable and Given schedule View Equal
hence serializable.
Final Write: T1 → T5
B T1 T5 No restriction
3. (3)
C T2
The conflicting pairs are:
Initial Read: -
w1(y) → w2(y)
Data IR Write -
w1(y) → w3(y) item
w2(y) → w3(y) A T1 -
only 3 conflict pairs exist in the given schedule.
5
D T3 -
Updated Read: T1 → T2
W1(B) → R2(B) T1 → T4
W1(B) → R4(B) T2 → T5
W2(C) → R5(C) T4 → T5
W4(E) → R5(E)
T1 → T2 → T5
T4 must be before T5 and T1 must be before T4
• T1 T4 T2 T5
• T1 T2 T4 T5
T3 can be anywhere there is no any restriction.
Total possibilities = 5 + 5 = 10
Hence, (10) is correct.
[MCQ] [MCQ]
1. Consider the following schedule S of transaction T1, T2 4. Consider the following transactions T1 and T2:
and T3. T1 T2
S: r1(x); r2(x); r3(y); w1(x); r2(z); r2(y); w2(y); w1(z); Read(A); Read(A);
Which one of the schedule below is the correct Update A = A + 100;
serialization of the above. Update A = A – 50;
(a) T2 T1 T3 Write(A);
(b) T3 T2 T1 Write(A);
(c) T3 T1 T2 The above transaction has _____.
(d) T2 T3 T1 (a) Lost update problem
(b) Dirty read problem
(c) Unrepeatable read problem
[MCQ]
(d) Incorrect summary problem
2. Consider the transactions T1, T2 and T3 and the
schedules S1 and S2 given below.
[MCQ]
T1: r1(A); r1(C); w1(A); w1(C)
5. Consider the following schedule.
T2: r2(B); r2(C); w2(C) Time T1 T2
T3: r3(B); r3(A); w3(B) t0 Read Item(A);
S1: r1(A); r3(B); r3(A); r2(B); r2(C); w3(B); w2(C); t1 Read Item(A);
r1(C); w1(A); w1(C) t2 A = A + X;
S2: r1(A); r3(B); r2(B); r3(A); r1(C); r2(C); w3(B); t3 Write Item(A);
w1(A); w2(C); w1(C) t4 Read Item(A);
Which one of the following statements about the
Which of the following concurrency problem exists in
schedule is TRUE?
the above given schedule?
(a) Only S1 is conflict serializable. (a) Dirty read (b) Unrepeatable read
(b) Only S2 is conflict serializable. (c) Lost update (d) Both a and b
(c) Both S1 and S2 are conflict serializable.
(d) Neither S1 nor S2 is conflict serializable. [MCQ]
6. ______Problem occurs when a transaction reads data
from a database, then another transaction reads the
[MCQ] same database data, and this particular data is deleted
3. Which of the following schedule is view serializable by an operation of the first transaction.
but not conflict serializable. (a) Dirty read
(a) r1(P); r2(P); w1(P); r2(Q) (b) Unrepeatable read problem
(b) r1(P); w1(P); r2(P); w2(Q) (c) Phantom read
(c) w1(P); w2(P); w1(P); w2(P); w1(P) (d) Lost update problem
(d) None of these.
2
Answer Key
1. (b) 6. (c)
2. (a) 7. (b)
3. (c) 8. (b)
4. (a) 9. (b, c)
5. (b)
4
From precedence graph, the correct serialization order We check for order of read in view serializability. In
is T3 T2 T1 order T2 T1, the schedule is view serializable.
4. (a)
2. (a)
The Transaction T1 first reads data A from the database
S1: r1(A); r3(B); r3(A); r2(B); r2(C); w3(B); w2(C); then transaction T2 reads the same data from the
r1(C); w1(A); w1(C) database. Then T1 Performs an operation to add 100 to
A. Then transaction T2 Performs an operation to
subtract 50 from the data read by T2. i.e., A. T1
performs a write operation to save the value of A
according to changes made to T1. Then T2 performs a
write operation to update the value of A again in the
As there is no cycle is precedence graph DB. This situation causes changes to A made by T1 to
be lost because T2 overwrites A again after T1 update
S1 is conflict serializable. A. you could also say that the update of T1 is lost.
S2: r1(A); r3(B); r2(B); r3(A); r1(C); r2(C); w3(B); Hence a is correct option.
w1(A); w2(C); w1(C)
5. (b)
In above schedule, T1 reads value of A and then again
reads the value of A. The Ist value of A is different from
other value in 2nd read.
Hence this is called unrepeatable read.
There exists a cycle hence it is not conflict serializable.
Hence, S1 is conflict serializable but S2 is not conflict 6. (c)
serializable. The phantom read problem arises when a transaction
reads a variable once but when it tries to read the same
variable again which was already deleted by other
3. (c) transaction, this problem known as phantom read
A : False problem.
Conflict serial schedule T1 T2 T3 T4 Cycle in the precedence graph, therefore not conflict
serializable.
9. (b, c)
For checking conflict serializability we make use of
precedence graph. For checking view serializability we
check for 3 conditions.
1. Initial read
2. Updated read
8. (b) 3. Final write
If a schedule is not conflict serializable and there exists
no blind write then we can conclude the schedule is not
view serializable too.
Precedence graph.