Polygraph to check View Serializabilty in DBMS

Prerequisite – Concurrency Control -Introduction, Conflict Serializability, Transaction Isolation Levels in DBMS
Serializability: If any transaction (non-serial) produce a outcome which is equal to the outcome of that schedule’s transaction executed serially then we can call that transaction schedule a Serializable schedule.

Note that the main objective of serializability is to find non-serial schedules that allow transactions to execute concurrently without interference and produce a database state that could be produced by a serial execution. These are following types of schedules:

  1. Serial schedule
  2. Conflict Serializability
  3. View Serializability
  4. Non-serial schedule

View Serializability –
A schedule is called View Serilizabale, if it’s view equivalent to a serial schedule (no overlapping transaction allowed). These are following condition to be a View Serializability:

  1. In the both shedule read of initial value of data item and write of final value of data item by transaction must be same.
  2. W->R conflict must be same in both shedule.

Now, lets consider following examples.

Example: Suppose there is two schedule one is non-serial and another one is serial schedule.

    Schedule 1              Schedule 2      
  --------------          ---------------
   T1      T2               T1      T2
  --------------          ---------------
  r1(A)                    r1(A)
  A=A+10                   A=A+10
  w1(A)                    w1(A)
  r1(B)                            r2(A)
  B=B*10                           A=A+10
  w1(B)                            w2(a)
          r2(A)            r1(B)                            
          A=A+10           B=B*10      
          w2(A)            w2(B)      
          r2(B)                    r2(B)
          B=B*10                   B=B*10
          w2(B)                    w2(B)  

Checking view serializable or not:

    Comparison Table
---------------------------
Schedule 1    Schedule 2
---------------------------
A   T1 T2         T1 T2
B   T1 T2         T1 T2 

So Schedule 2 is view equivalent to Schedule 1.

Using polygraph when the number of transactions is more than 2:
Suppose we have 3 transactions T1, T2, and T3. Possible combination of those transactions are:

--------------
 T1   T2   T3
 T1   T3   T2
 T2   T1   T3
 T2   T3   T1
 T3   T1   T2
 T3   T2   T1
-------------- 

1. A Tn reads an initial data in a schedule the same Tn also should read the initial data in one of the transaction combination. That means T1 should occur before T2, so we have to remove these combinations:

--------------
 T2   T1   T3
 T2   T3   T1
 T3   T2   T1
-------------- 

2. A Tn reads a data after another Tn has written in a schedule, the same Tn also should read after another Tn has written it in one of transaction combination.

3. A Tn writes the final value for a data in a schedule, the same Tn should also write the final data in one of the transaction combination. That means T2 occur before T3, so we have to remove these combinations:

--------------
 T1   T3   T2
 T3   T1   T2
 T3   T2   T1
-------------- 

Example:

Schedule = w3(x),r2(x),w2(y),r1(z),w3(y),w1(y) 
  T1   T2    T3
----------------
            w(x)
     r2(x)
     w2(y)
r1(z)
           w3(y)
w1(y)
---------------- 

Here T3 must occuar first, though it actually does not matter because of no one else writes X, we will keep all the possible transaction combination in the first step.

T1 must occur after T3 because T1 reads Z after T3 writes it. So here we remove those three combinations of transaction where T1 is before than T3.

Available combination:
 T2 T3 T1
 T3 T1 T2
 T3 T2 T1 

T2 must occur last cause if not T3 or T2 will overwrite y that T1 writes in our schedule, so we remove from available combination where T1 is not occurring last.

Available combination:
 T2 T3 T1
 T3 T2 T1 

Note that we use Polygraph when a blind write is available in any transaction.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.