Open In App

View Serializability in DBMS

Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite – Types of Schedules in DBMS 

The View serializability is a concept that is used to compute whether schedules are View-Serializable or not. A schedule is said to be View-Serializable if it is view equivalent to a Serial Schedule (where no interleaving of transactions is possible). 

Need of View-Serializability

There may be some schedules that are not Conflict-Serializable but still gives a consistent result because the concept of Conflict-Serializability becomes limited when the Precedence Graph of a schedule contains a loop/cycle. In such a case we cannot predict whether a schedule would be consistent or inconsistent. As per the concept of Conflict-Serializability, We can say that a schedule is Conflict-Serializable (means serial and consistent) if its corresponding precedence graph does not have any loop/cycle. 

But, what if a schedule’s precedence graph contains a cycle/loop and is giving consistent result/accurate results as a conflict serializable schedule is giving? 
 

So, to address such cases we brought the concept of View-Serializability because we did not want to confine the concept of serializability only to Conflict-Serializability. 

Example: Understanding View-Serializability first with a Schedule S1 : 

T1 T2 T3
a=100 
read(a) 
 
   
  a=a-40 
write(a) //60 
 
 
a=a-40 
write(a) //20 
 
   
    a=a-20 
write(a) //0 
 

So, its Conflict Precedence Graph is as follows – 
 

 

The above graph contains cycle/loop which means it is not conflict-serializable but it does not mean that it cannot be consistent and equivalent to the serial schedule it may or may not be. 
 

LookSchedule S’1 : 

In the above example if we do swapping among some transaction’s operation so our table will look like this – 

T1 T2 T3
a=100 
read(a) //100 
 
   
a=a-40 
write(a) //60 
 
   
  a=a-40 
write(a) //20 
 
 
    a=a-20 
write(a) //0 
 

Its Precedence Graph is as follows – 
 

 

Now, we see that the precedence graph of the second table does not contain any cycle/loop, which means it is conflict serializable (equivalent to serial schedule, consistent) and the final result is coming the same as the first table. 

Note: In the above example we understood that if a schedule is Conflict-serializable so we can easily predict that It would be –  

  1. Equivalent to a serial schedule,
  2. Consistent,
  3. And also a View-Serializable.

But what if it is non-conflict serializable (precedence graph contains loop). In this situation, we cannot predict whether it is consistent and serializable or not. As we look in the above example, where the precedence graph of Schedule S1 was giving consistent results, equivalent to the serializable result of Schedule S’1, despite containing cycles/loops. So, to address the limitation of the Conflict-Serializability concept View-Serializability method came into the picture. 

Method-1 : 
Two schedules S1 and S2 are said to be view-equivalent if the following conditions are agreed upon – Go to Link: Point number 3. 

Method-2 : 
First of all, check whether the given schedule is Non-Conflict Serializable or Conflict-Serializable – 

  • If the given schedule is conflict serializable (which means its precedence graph does not contain any loop/cycle), then the given schedule must be a view serializable. Stop and submit your final answer.
  • If the given schedule is non-conflict serializable, then it may or may not be view serializable. We cannot predict it just by using the concept of conflict serializability, So we need to look at the below cases.

After performing the above steps if you find the provided schedule is non-conflicting you need to perform the following steps – 

Blind write: Performing the Writing operation (updation), without reading operation, a such write operation is known as a blind write. 

  • If no blind write exists, then the schedule must be a non-View-Serializable schedule. Stop and submit your final answer.
  • If there exists any blind write, then, in that case, the schedule may or may not be view serializable. So we need to look at the below cases. Because, if it does not contain any blind write, we can surely state that the schedule would not be View-Serializable.
  • If the above two conditions do not work {which means we have tried the above 2 conditions, then we have come to this step}. Then, draw a precedence graph using those dependencies. If no cycle/loop exists in the graph, then the schedule would be a View-Serializable otherwise not.

Problem: Prove whether the given schedule is View-Serializable or not. 

S' : read1(A), write2(A), read3(A), write1(A), write3(A)

Solution: First of all we’ll make a table for a better understanding of given transactions of schedule S’- 

T1 T2 T3
read(a)    
  write(a)  
    read(a)
write(a)    
    write(a)
  • First, we check whether it is Conflict-Serializable or not, because if it is Conflict-Serializable so it will also be View-Serializable, so we will make a precedence graph for the schedule S’.
  • Here we will check whether the Schedule s’ contains any blind write. We found that the schedule s’ contains a blind-write write2(a) in transaction T2. Hence schedule S’ may or may not be View-Serializable. So we will look at another method. Because, if it does not contain any Blind-write, we can surely state that the schedule would not be View-Serializable.
  • Now, we will draw a dependency graph that is different from the precedence graph.

Its Dependency graph will be followed as:
 

Fig. Precedence Graph

  • Transaction T1 first reads data_item “a” and transaction T2 first updates(write) “a”.
  • So, the transaction T1 must execute before T2.
  • In that way, we get the dependency (T1 → T2) in the graph.
  • And, the final update(write) on “a” is made by transaction T3.
  • So, transaction T3 must execute after all the other transactions(T1, T2).
  • Thus, we get the dependency (T1, T2) → T3 in the graph shown below:

impove

Fig. Dependence Graph

As there is no cycle/loop in the dependency graph, the schedule S’ is View-Serializable.



Last Updated : 08 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads