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

Databases System. Exercise 18.2.1. Below are two transactions, described in term

ID: 3824258 • Letter: D

Question

Databases System. 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.

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

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, (T1 ,T2) and (T2,T1)  are equivalent.

The question: Demonstrate this fact by showing the effect of the two transactions on an arbitrary initial database state.

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.

=======================================================================================

please let me know in case of any clarification.

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