![]() |
VOOZH | about |
In database systems, concurrent execution of transactions is used to improve resource utilization and system throughput. However, concurrency can lead to inconsistencies in the database if not handled properly.
Example: Understanding View-Serializability first with a Schedule:
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.
Schedule 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:
The graph of S'1 has no cycles, meaning itβs conflict serializable and view serializable.
Note: In the above example we understood that if a schedule is Conflict-serializable so we can easily predict that It would be
If a schedule is view equivalent to a serial schedule, itβs view serializable. This requires three conditions:
Read more about Condition of Schedules to be View Equivalent, Here.
Another method to check view serializability starts by testing conflict serializability through the precedence graph and then check for Blind Writes following checking the cycle in dependency graph.
Example 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'. From precedence graph, we can conclude that the schedule is not conflict serializable (as there is a loop or cycle in precedence graph).
π ImageNow, 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.
Now, we will draw a dependency graph.
As there is no cycle/loop in the dependency graph, the schedule S' is View-Serializable.