Exercise 18.2.1 Below are two transactions, described in terms of their effect o
ID: 3841713 • Letter: E
Question
Exercise 18.2.1 Below are two transactions, described in terms of their effect on two database elements A and B, which we may assume are integers Th: READ (A,t) t: t+2; WRITE CA ,t) READ Bit); t t*3; WRITE Bit) T2: READ B, s) s s* 2: WRITE B,s) READ A, s) s s 3; WRITE (A, s) CHAPTER 18. CONCURRENCY CONTROL 896 We assume that, whatever consistency constraints there are on the database, these transactions preserve them in isolation. Note that A B is not the consistency constraint. a) It turns out that both serial orders have the same effect on the database, that is, (Th,T2) and (T2,T1) are equivalent. Demonstrate this fact by showing the effect of the two transactions on an arbitrary initial database State. b) Give examples of a serializable schedule and a nonserializable schedule of the 12 actions above. c How many serial schedules of the 12 actions are there? d) How many serializable schedules of the 12 actions are there?Explanation / Answer
Hi,
Please find the anser to the question below:-
Given:-
T1: READ(A,t); t:= t+ 2 ; WRITE(A , t ) ; READ(B,t); t:= t* 3 ; WRITE(B,t);
T2: READ(B,s); s:= s*2; WRITE(B,s); READ(A,s); s:=s+3; WRITE(A.s);
TRANSACTIONS ARE SERIAL
Answer:-
Now performing transactions T1 then T2
Assuming in database initially t=2,s=2,A=1,B=1
Now transaction when executed in order (T1, T2)
EXECUTING T1:-
READ(A,t)
t:= t+ 2
WRITE(A , t )
READ(B,t)
t:= t* 3
WRITE(B,t);
Read(1,2)
t=4
WRITE(1 , 4 )
READ(1,4)(The modified value is read now)
t=4*3=12
WRITE(1,12);
A=1,t=1
A=1,t=4
A=1,t=4
A=1,B=1,t=4
A=1,B=1,t=12
A=1,B=1,t=12
EXECUTING T2:-
READ(B,s)
s:= s* 2
WRITE(B , s )
READ(A,s)
S=s+ 3
WRITE(A.s);
Read(1,2)
s=4
WRITE(1 , 4 )
READ(1,4)(The modified value of s is read now)
s=7
WRITE(1.7);
B=1,s=2
B=1,s=4
B=1,s=4
A=1,B=1,s=4
A=1,B=1,s=7
A=1,B=1,s=7, write 7 to a memory location
RESULT1 :-Hence values of A, B, t and s when transaction executed (T1, T2) is:-
A=1, B=1, t=12, s=7 and to some location 7
Now transaction when executed in order (T2, T1)
Assuming in database initially t=2,s=2,A=1,B=1
EXECUTING T2:-
READ(B,s)
s:= s* 2
WRITE(B , s )
READ(A,s)
S=s+ 3
WRITE(A.s);
Read(1,2)
s=4
WRITE(1 , 4 )
READ(1,4)(The modified value of s is read now)
s=7
WRITE(1.7);
B=1,s=2
B=1,s=4
B=1,s=4
A=1,B=1,s=4
A=1,B=1,s=7
A=1,B=1,s=7, write 7 to a memory location
EXECUTING T1:-
READ(A,t)
t:= t+ 2
WRITE(A , t )
READ(B,t)
t:= t* 3
WRITE(B,t);
Read(1,2)
t=4
WRITE(1 , 4 )
READ(1,4)(The modified value is read now)
t=4*3=12
WRITE(1,12);
A=1,t=1
A=1,t=4
A=1,t=4
A=1,B=1,t=4
A=1,B=1,t=12
A=1,B=1,t=12
RESULT2:-Hence values of A, B, t and s when transaction executed (T2, T1) is:-
A=1, B=1, t=12, s=7 and to some location 7
CONCLUSION:-
Comparing result1 and result 2 it can be found that even both serial orders have the same effect on the database; that is, (T1 ,T2) and (T2,T1) are equivalent.
HOPE IT HELPS ^_^
READ(A,t)
t:= t+ 2
WRITE(A , t )
READ(B,t)
t:= t* 3
WRITE(B,t);
Read(1,2)
t=4
WRITE(1 , 4 )
READ(1,4)(The modified value is read now)
t=4*3=12
WRITE(1,12);
A=1,t=1
A=1,t=4
A=1,t=4
A=1,B=1,t=4
A=1,B=1,t=12
A=1,B=1,t=12
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.