Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Advanced Databases / SQL Transaction S: read(a); a=a+10; write(a); read(b); b=b*

ID: 3738002 • Letter: A

Question

Advanced Databases / SQL

Transaction S:

read(a);

a=a+10;

write(a);

read(b);

b=b*5;

write(b);

Transaction T:

read(a);

a=a*2;

write(a);

1) If the initial value of a is 10 and the initial value of b is 20, what are their final values if we perform the transactions serially, using order S,T?

2) Using the same initial values, what are the final values of a and b if the order of execution is T,S?

3) Does this result have any implications for serializability?

4) Write a concurrent schedule for transactions S and T that illustrates the lost update problem.

5) Apply the standard two-phase locking protocol to the schedule you devised in step 4. Will the protocol allow the execution of that schedule? Does deadlock occur?

Explanation / Answer

Question 1)

Transaction S:

read(a); ->a=10

a=a+10; ->a=20

write(a); ->a=20 written

read(b); ->b=20

b=b*5; ->b=100

write(b); ->b=100 written

Transaction T:

read(a); ->a=20

a=a*2; ->a=40

write(a); ->a=40 written

Final values of a=40 and b=100

Question 2)

Transaction T:

read(a); ->a=10

a=a*2; ->a=20

write(a); ->a=20 written

Transaction S:

read(a); ->a=20

a=a+10; ->a=30

write(a); ->a=30 written

read(b); ->b=20

b=b*5; ->b=100

write(b); ->b=100 written

Final values of a=30 and b=100

Question 3)

Yes, it will have implications for serializability

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote