0% found this document useful (0 votes)
25 views16 pages

Transaction & Concurrency Control DPP 03 (Of Lec 08) 2

The document contains a series of questions and answers related to Transaction and Concurrency Control in Database Management Systems. It includes multiple-choice questions (MCQs) and natural questions (NATs) that assess understanding of concepts such as conflict serializability, view serializability, and recovery methods. Additionally, it provides hints and solutions for the questions posed.

Uploaded by

om717102
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views16 pages

Transaction & Concurrency Control DPP 03 (Of Lec 08) 2

The document contains a series of questions and answers related to Transaction and Concurrency Control in Database Management Systems. It includes multiple-choice questions (MCQs) and natural questions (NATs) that assess understanding of concepts such as conflict serializability, view serializability, and recovery methods. Additionally, it provides hints and solutions for the questions posed.

Uploaded by

om717102
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

1

Branch : CSE & IT Batch : Hinglish


Database Management System
Transaction & Concurrency Control DPP 03

[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

Which one of the following statements is TRUE? Time T1 T2


(a) S1 is recoverable and S2 is not recoverable. t0 read(P);
(b) S1 is not recoverable and S2 is recoverable. t1 write(P);
(c) Both S1 and S2 are recoverable. t2 read(R);
(d) Both S1 and S2 are not recoverable. t3 write(R);
t4 read(Q);
[MCQ] t5 write(Q);
10. Consider the following schedule: t6 read(P);
S: r1(A); r2(C); w1(A); r3(A) r2(B); w2(B), w3(A); t7 commit;
r3(B); r2(A)
t8 read(Q);
for the schedule S given above two orderings of
commits (ci) operations are specified.
I. c1; c3; c2 Suppose that the transaction T1 fails immediately after
time instance 8. Which one of the following is correct?
II. c1; c2; c3
S1: Schedule S is non recoverable and cannot ensure
Which of the above ordering ensures recoverability of
transaction atomicity
schedule S?
S2: Only T2 should be aborted and then restarted to
(a) Only I
ensure truncation atomicity
(b) Both I and II
(a) Only S1 is true
(c) Only II
(b) Only S2 is true
(d) None of these
(c) Both S1 and S2 are true
(d) Both S1 and S2 are false
[MCQ]
11. Consider the following partial schedule ‘S’ involving
two transaction T1 and T2
3

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

Hints & Solutions


1. (8) Total 10 topological orders.
Given schedule As we know that number of serial schedule conflict ‘S’
S: w1(X); w1(Y); r2(X); w2(Y);r3(X);w3(Y) is equal to number of topological orders.
Conflict equivalent schedules to above schedules.
3. (10)
Final write Q: T1 T5
Initial Reads
Data item Initial reads Writes
P T1 -
Q - T1 T5
R - T2
There are 2 ways r2(X) placed such that it must be
before w2(Y) and conflicting pairs should be in S T3 -
precedence. T - T4
Hence 2 possibilities to place r2(x) to avoid conflict Updated reads
equivalence in above schedule. w1(Q) → r2(Q)
S = w1(X) r2(X) w1(Y) w2(Y) w3(Y) r4(Q)
T5 also writes Q
r3(X) w2(R) → r5(Q)
4 ways
w4(T) → r5(T)
S = w1(X); w1(Y) r2(X) w2(Y) w3(Y)
T1 T5

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

T4 can be placed in two ways


1) T1 T2 T4 T5
Topological orders
T1 T2 T4 T5 T3
5 ways
T3
2) T1 T4 T2 T5
5 ways
Topological orders
T3
T1 T4 T2 T5
5 ways
 There are 10 serial orders.
T3

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).

6. (a) 10. (d)


only allow concurrent execution of transaction that T1 T2 T3
correspond to serial execution of some of the r1(A)
transactions. r2(c)
w1(A)
7. (d) r3(A)
All the problems mentioned in option are potential r2(B)
when a DBMS executes multiple transactions w2(B)
concurrently. w3(A)
r3(B)
r2(A)
8. (b)
c1
Every conflict serializable schedules are view c3
serializable but vice versa is not true. However, some c2
view serializable schedules are conflict serializable.
T3 reads the changes of T2 corresponding to B and
commits itself before T2. So this schedule is not
9. (a) recoverable
S1:
T1 T2 T3 T1 T2 T3
r1(A) r1(A)
r2(A) r2(c)
w2(A) w1(A)
r3(A) r3(A)
w1(A) r2(B)
w2(B) w2(B)
r3(B) w3(A)
c2 r3(B)
w3(A) r2(A)
c1 c1
c3 c2
c3
Here the transaction reads the changes of T2 reads the changes of T3 Corresponding to A
uncommitted transaction but commits itself. So and commits itself before committing of T3. So
schedule is recoverable. this schedule is also not recoverable. Hence
answer is option (d).
6

11. (a) by other transaction and then gets committed itself


T1 gets faild after t8, as T1 is uncommitted at t1 time hence it is non recoverable.
and write (P) and T2 reads P at t6 and gets committed. T1 gets failed hence not atomic. Hence correct option
Hence uncommitted transaction changes are got read is a.

Any issue with DPP, please report by clicking here:- https://forms.gle/t2SzQVvQcs638c4r5


For more questions, kindly visit the library section: Link for web: https://smart.link/sdfez8ejd80if

PW Mobile APP: https://smart.link/7wwosivoicgd4


1

Branch : CSE & IT Batch : Hinglish


Database Management System DPP-01
Transaction and Concurrency Contro

[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

If a crash occurs just after step 9. Which of the


[MCQ] following is the correct way for recovery?
7. Consider the following log which consists of (a) Undo (T3) then Undo (T1) then Redo (T2)
transactions T1, T2 and T3: (b) Redo (T3) then Undo (T1) then Undo (T2)
Step Details of log (c) Undo (T3) then Redo (T1) then Redo (T2)
1 <T1 Start> (d) None of these.
2 <T1, A, 200, 300>
3 <T1, A, 600, 500> [NAT]
4 <T2 start> 8. Consider the following schedule
5 <T1 commit> S: R1(A), R3(D), W1(B), R2(B), R4(B), W2(C),
6 <T2, B, 600, 400> R5(C), W4(E), R3(E), W5(B)
7 <T2 commit> How many serial schedules are possible which will be
8 <T3 start> view equal to S? __________.
9 <T3, A, 600, 100>
3

Answer Key

1. (2) 5. (b)
2. (b, c) 6. (c)
3. (3) 7. (c)
4. (b) 8. (10)
4

Hints & Solutions


1. (2) 4. (b)
Two operations are called conflicting if the below Isolation allows the multiple transaction to
conditions: occur at the same time without impacting each
I: They work on same data item. other’s execution. The property which first
violated is Isolation that result in loss of
II: Both the operations belong to different
consistency or result will be incorrect.
transactions.
5. (b)
III: There exists one write operation.
T1: R(A) T2: R(B)
Therefore, only two statements are correct.
R(B) R(A)
W(B) W(A)
2. (b, c)
If a schedule S is either conflict serializable or view T1 → T2: ........ W(B) R(B).......
serializable or both then it is serializable. T2 → T1: ........ W(A) R(A) ......
I: Checking conflict serializability using • There is no possibility of non-serial schedule
precedence graph. which becomes serializable by T2 followed by
T1 and T1 followed by T2
• A serial schedule is always serializable but it is
asking about the non-serial schedule.
Hence, option (b) is correct.

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.

Any issue with DPP, please report by clicking here:- https://forms.gle/t2SzQVvQcs638c4r5


For more questions, kindly visit the library section: Link for web: https://smart.link/sdfez8ejd80if

PW Mobile APP: https://smart.link/7wwosivoicgd4


1

Branch : CSE & IT Batch : Hinglish


Database Management System
Transaction & Concurrency Control DPP 02

[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

[MCQ] (c) S may or may not be view serializable schedule.


7. Consider a schedule S: (d) None of these
r1(x), r2(y), w2(x), w3(z), r4(z), r3(x), w3(y), r4(x), w4(y)
[MSQ]
Choose the correct statements for the above schedule
S. 9. Choose the correct statements from the following.
(a) To test view serializability we make use of
(a) The schedule S is not serializable.
precedence graph
(b) The schedule S is conflict serializable with (b) To test conflict serializability we make use of
schedule S as T1T2T3T4. precedence graph.
(c) The schedule S is not view serializable. (c) If there exists no blind write and the schedule is
(d) None of the above. not conflict serializable then we can conclude that
it is not view serializable.
(d) All of the above.
[MCQ]
8. Consider the below schedule.
S: r1(A), r2(B), w2(A), r3(A), w1(B) w3(A)
choose the correct statement from the following.
(a) S is conflict serializable schedule.
(b) S is not conflict serializable schedule.
3

Answer Key
1. (b) 6. (c)
2. (a) 7. (b)
3. (c) 8. (b)
4. (a) 9. (b, c)
5. (b)
4

Hints & Solutions


1. (b) T1 T2
Conflict operation are W1(P)
R2(X); W1(X); R3(Y); W2(Y), R2(Z); W1(Z) W2(P)
W1(P)
W2(P)
W1(P)

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.

It is conflict serializable, hence it is also view


7. (b)
serializable.
B : False

It is conflict serializable, hence it is also view


serializable.
C : True

It is not conflict serializable, hence checking for view


serializable. for conflict serializability, we check precedence graph.
5

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.

Any issue with DPP, please report by clicking here:- https://forms.gle/t2SzQVvQcs638c4r5


For more questions, kindly visit the library section: Link for web: https://smart.link/sdfez8ejd80if

PW Mobile APP: https://smart.link/7wwosivoicgd4

You might also like