View Serializability in DBMS - GeeksforGeeks

10 Jun, 2021
Prerequisite – Types of Schedules in DBMS 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). 
Why do we need to use 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) iff 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 result 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 serializability only to Conflict-Serializability. 
Example : Understanding View-Serializability first with a Schedule S1 : 
 
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 – 
 
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 –  
Equivalent to a serial schedule,Consistent,And also a View-Serializable.
Equivalent to a serial schedule,
Consistent,
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 the Schedule S1 was giving consistent result, equivalent to the serializable result of the Schedule S’1, despite containing cycles/loops. So, to address the limitation of the Conflict-Serializability concept View-Serializability method came into the picture. 
Methods to check View-Serializability of a schedule – 
Method-1 : Two schedules S1 and S2 are said to be view-equivalent if the following conditions are agreed – 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 (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, 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 {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 better understanding of given transactions of schedule S’- 
 
 
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 the 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 which is different from precedence-graph.
Its Dependency graph will be followed as –  
 
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, final update(write) on “a” is made by the 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.
As there is no cycle/loop in the dependency graph, the schedule s’ is View-Serializable. 
karan dhama
DBMS
GATE CS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Deadlock in DBMS
KDD Process in Data Mining
Types of Functional dependencies in DBMS
Conflict Serializability in DBMS
Introduction of Relational Algebra in DBMS
Layers of OSI Model
TCP/IP Model
Types of Operating Systems
Page Replacement Algorithms in Operating Systems
Differences between TCP and UDP