Answered step by step
Verified Expert Solution
Question
1 Approved Answer
need help with a and b (a) (6 marks) Consider a database with objects A, B and C, and the following two trans- actions Ti
need help with a and b
(a) (6 marks) Consider a database with objects A, B and C, and the following two trans- actions Ti and T2 involving those objects T1 begin transaction begin.transaction read(A) read (B) read (C) If A = 0, C := C+1 write (B) write(C) commit read (A) read (B) read (C) If B = 0, A:=A+1 C := C+1 write (A) write(C) commit B:= B+1 Let the initial values of A, B and C be 0; and the consistency requirement be either A 0 or B = 0 (i) Show that every serial execution of these two transactions preserves the consis- tency of the database (ii) Give an example of a non-serial schedule involving all the operations that con stitute transactions T] and T2 such that it (the non-serial schedule schedule you constructed) results in a lost update problem. observe the two-phase locking protocol (2PL) problem as identified in (ii) above (iii) Add lock and unlock instructions to the transaction Ti and T2 so that they (iv) Explain how the use of two-phase locking protocol can resolve the lost update (b) (4 marks) Discuss whether any concurrent execution of the two transactions Ti and T2 shown in part (a) can result in a deadlock. In your answer focus only on the lock/unlock instructions that you have introduced in part a(iii). If there is a deadlock, describe how could it have been prevented, if at all (a) (6 marks) Consider a database with objects A, B and C, and the following two trans- actions Ti and T2 involving those objects T1 begin transaction begin.transaction read(A) read (B) read (C) If A = 0, C := C+1 write (B) write(C) commit read (A) read (B) read (C) If B = 0, A:=A+1 C := C+1 write (A) write(C) commit B:= B+1 Let the initial values of A, B and C be 0; and the consistency requirement be either A 0 or B = 0 (i) Show that every serial execution of these two transactions preserves the consis- tency of the database (ii) Give an example of a non-serial schedule involving all the operations that con stitute transactions T] and T2 such that it (the non-serial schedule schedule you constructed) results in a lost update problem. observe the two-phase locking protocol (2PL) problem as identified in (ii) above (iii) Add lock and unlock instructions to the transaction Ti and T2 so that they (iv) Explain how the use of two-phase locking protocol can resolve the lost update (b) (4 marks) Discuss whether any concurrent execution of the two transactions Ti and T2 shown in part (a) can result in a deadlock. In your answer focus only on the lock/unlock instructions that you have introduced in part a(iii). If there is a deadlock, describe how could it have been prevented, if at allStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started