DATABASE
MANAGEMENT
SYSTEM
CONTENTS
Equivalence of two schedules
Serializability
Serializable Schedules
Conflict Serializabilty
View Serializability
WHEN TWO SCHEDULES ARE EQUIVALENT?
There are three types of equivalence of schedules :
⚫ Result equivalence
⚫ Conflict equivalence
⚫ View equivalence
RESULT EQUIVALENCE
In results equivalence, the end result of schedules heavily depends on input of schedules. The final
values are calculated from both schedules and check whether they are equal or not.
Example is as follows:-
These two schedules are
not result equivalence.
CONTINUE…
One more example is as follows:-
S1 S2
When x=20 then output of s1 T1 T2 T1 T2
is 23. Similarly on x=20 R(x) R(x)
output of s2 is 23. x=x+10 x=x-5
When x=10 then output of s1
W(x) W(x)
is 13. Similarly on x=10 output
of s2 is 13. So these two C C
schedules are result R(x) R(x)
equivalence. x=x-7 x=x+8
W(x) W(x)
C C
CONFLICT EQUIVALENCE
Two schedules are said to be conflict equivalence if and only if:
⚫ They contain the same set of the transaction.
⚫ If each pair of conflict operations are ordered in the same way.
Consider following two schedules then check whether these two schedules are conflict equivalent
or not:
S1: R1(A) W1(A) R2(A) W2(A) R1(B) W1(B) R2(B) W2(B)
S2: R1(A) W1(A) R1(B) W1(B) R2(A) W2(A) R2(B) W2(B)
CONTINUE…
Both schedules having same number of transaction T1 and T2. Both having same set of
operations.
Now find out the conflicting operations of S1 and S2. All the conflicting operations should be on
the same order.
S1: R1(A) W1(A) R2(A) W2(A) R1(B) W1(B) R2(B) W2(B)
S2: R1(A) W1(A) R1(B) W1(B) R2(A) W2(A) R2(B) W2(B)
For S1 Conflicting Pairs are: For S2 Conflicting Pairs are:
R1(A)W2(A) R1(A)W2(A)
W1(A)R2(A) So these two schedules are W1(A)R2(A)
W1(A)W2(A) conflict equivalent. W1(A)W2(A)
R1(B)W2(B) R1(B)W2(B)
W1(B)R2(B) W1(B)R2(B)
W1(B)W2(B) W1(B)W2(B)
VIEW EQUIVALENCE
Two schedules are said to be view equivalence if and only if:
Initial Read
• An initial read of both schedules must be the same. Suppose two schedule S1
and S2. In schedule S1, if a transaction T1 is reading the data item A, then in S2,
transaction T1 should also read A.
Updated Read/Producer - consumer pair (WR)
• In schedule S1, if Ti is reading A which is updated by Tj then in S2 also, Ti
should read A which is updated by Tj.
Final Write
• A final write must be the same between both the schedules. In schedule S1, if a
transaction T1 updates A at last then in S2, final write operation should also be
done by T1.
CONTINUE…
Check whether the following two schedules S1 and S2 are view equivalent or not.
S1 S2
Data Initial Final Producer - Consumer
For S1 Item Read Write Pair T1 T2 T1 T2
A T1 T2 T1🡪T2
Hence these two
schedules are view R(A) R(A)
equivalent. B T1 T2 T1🡪T2 W(A) W(A)
R(B)
R(A) W(B)
For S2 Data Initial Final Producer - Consumer
W(A) R(A)
R(B) W(A)
Item Read Write Pair
W(B) R(B)
A T1 T2 T1🡪T2
W(B)
R(B)
B T1 T2 T1🡪T2 W(B)
SERIALIZABLE SCHEDULE
Basic Assumption – Each transaction preserves database consistency.
Thus serial execution of a set of transactions preserves database consistency.
A (possibly concurrent) schedule is serializable if it is equivalent to a serial schedule.
In other words, Serializable schedules are always considered to be correct when concurrent
transactions are executed.
DIFFERENCE BETWEEN SERIAL SCHEDULE AND SERIALIZABLE
SCHEDULE
The main difference between the serial schedule and the serializable schedule is that in serial
schedule, no concurrency is allowed whereas in serializable schedule, concurrency is allowed.
In serial schedule, if there are two transaction executing at the same time and if no interleaving
of operations is permitted, then there are only two possible outcomes for T1 and T2 schedule.
⚫ Execute all the operations of transaction T1 (in sequence) followed by all the operations
of transaction T2 (in sequence).
⚫ Execute all the operations of transaction T2 (in sequence) followed by all the operations of
transaction T1 (in sequence).
In serializable schedule, if there are two transaction executing at the same time and if
interleaving of operations is allowed, there will be many possible orders in which the system
can execute the individual operations of the transactions.
SERIALIZABILITY
Based on the types of equivalence, we define the two types of serializability.
⚫ Conflict serializability
A schedule S is conflict serializable if it is conflict equivalent to a serial
schedule.
⚫ View serializability
A schedule S is view serializable if it is view equivalent to a serial schedule.
EXAMPLE
Check whether the given schedule is conflict serializable or not.
S: R1(x) R2(x) W1(x) R1(x) W2(x)
⚫ Number of transactions involved in this schedule is T1 and T2.
⚫ Now find out conflicting pairs:
R1(x) W2(x)
R2(x) W1(x)
W1(x) W2(x)
⚫ T1 T2
⚫ R1(x) W1(x) R1(x) R2(x) W2(x)
R1(x)W2(x)
W1(x)R2(x)
W1(x)W2(x)
⚫ T2 T1
⚫ R2(x) W2(x) R1(x) W1(x) R1(x)
R2(x)W1(x)
W2(x)R1(x)
W2(x)W1(x)
HOW TO TEST CONFLICT SERIALIZABILITY
We can test the conflict serializabilty of a schedule by precedence graph method. The steps of
forming this graph is as follows:-
First write the given schedule in a linear way if it is not linear.
Draw the number of nodes of the graph equals to the number of transaction of the given schedule.
Find the conflicting pairs (RW, WR, WW) on same variable by different transactions.
Whenever conflict pairs are find, write the dependency relation like Ti → Tj, if conflict pair is
from Ti to Tj. For example, (W1(A), R2(A)) ⇒ T1 → T2
Draw the edge for each conflicting pair like 1st node to 2nd node.
Check to see if there is a cycle formed,
If yes then schedule is not conflict serializable.
If no then schedule is conflict serializable.
EXAMPLE
Check whether the given schedule is conflict serializable or not.
S: R1(x) R2(x) W1(x) R1(x) W2(x)
⚫ Number of transactions involved in this schedule is T1 and T2. So the nodes will be 1 and 2.
⚫ Now find out conflicting pairs:
R1(x) W2(x)
R2(x) W1(x)
W1(x) W2(x)
1 2
There is a cycle formed so it
is not conflict serializable
1
schedule.
PRACTICE PROBLEMS
Check whether the given schedule is conflict serializable or not.
1) S: R2(Z) R2(y) W2(y) R3(y) R3(z) R1(x) W1(x) W3(y) W3(z) R2(x) R1(y) W1(y)
W2(x).
2) S: R2(z) R2(y) W2(y) R3(y) R3(z) R1(x) W1(x) W3(y) W3(z)
HOW TO TEST VIEW SERIALIZABILITY
If (Conflict
Serializable)
No
Yes
If (Blind Write)
Yes No S is view
Check for View Not view Serializable
Serializable Serializable
EXAMPLE
Check whether the given schedule is view serializable or not.
S : R2(B); W2(A); R1(A); R3(A); W1(B); W2(B); W3(B)
Solution:
⚫ Step 1: Find out the total number of possible serial schedule i.e. m!
Total number of transactions involved in the schedule is 3
so 3!=6.
<T1 T2 T3>
<T1 T3 T2>
<T2 T3 T1>
<T2 T1 T3>
<T3 T1 T2>
<T3 T2 T1>
CONTINUE…
Step 2: Find out the initial read for each data item.
Step 3: Find out the final write for each data item .
Step 4: Find out the producer -consumer pair.
Data Initial Final Producer-Consumer
Item Read Write Pair
A T1 T2 T2🡪T1, T2 🡪 T3
B T2 T3 -----
CONTINUE…
Since final write on B is performed by T3 transaction.
Now, Removing those schedules in which T3 is not executing at last.
Remaining Schedules are:-
<T1 T2 T3>
<T2 T1 T3>
Now arrange the operations according to <T1 T2 T3>
S : R1(A);W1(B); R2(B); W2(A);W2(B); R3(A);W3(B);
Repeat the steps from 2 to 4.
Data Initial Final Producer-Consumer Data Initial Final Producer-Consumer
Item Read Write Pair Item Read Write Pair
A T1 T2 T2 🡪 T1, T2 🡪 T3 A T1 T2 T2🡪T3
B T2 T3 ----- B T2 T3 T1🡪T2
CONTINUE…
Compare the entries of both the table if we get the same entry for each cell that means the given
schedule is view serializable, if any of the entry is not matched then repeat the same process for other
possible serial schedule.
One more possible serial schedule for this example is <T2 T1 T3>
Now arrange the operations according to <T2 T1 T3>
S : R2(B); W2(A);W2(B); R1(A);W1(B);R3(A);W3(B);
Repeat the steps from 2 to 4.
Data Initial Final Producer-Consumer Data Initial Final Producer-Consumer
Item Read Write Pair Item Read Write Pair
A T1 T2 T2🡪T1, T2🡪T3 A T1 T2 T2🡪T1, T2🡪T3
B T2 T3 ----- B T2 T3 -----
Yes it is view serilizable Schedule
THANKS