Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Difference between Con ict and

View Serializability

Serializable Schedule :
A transaction schedule is serializable if its outcome is equal to
the outcome of its transactions executed serially i.e.
sequentially without overlapping in time. A serializable schedule
always leaves the database in consistent state. A serial
schedule is always a serializable schedule because a new
transaction only starts when the older one has nished
execution.

Example –
Let us consider the following schedule and see if it is
serializable.

T1 T2

R(X)

R(X)

R(Y)

W(Y)

R(Y)

W(X)
fl
fi
Now, let us gure out if the above schedule is serializable.

1. Swapping R(X) of T1 and R(Y) of T2.


2. Swapping R(X) of T1 and W(Y) of T2.

T1 T2

R(X)

R(Y)

W(Y)

R(X)

R(Y)

W(X)

Thus, after changing the con icting operations in the initial


schedule we get a serial schedule. Hence, this schedule is
serializable.

Types of Serializable Schedules :


1. Result Equivalent Schedule
2. Con ict Equivalent Schedule or Con ict Serializability
3. View Equivalent Schedule or View Serializability

Difference between Con ict and View Serializability :


fl
fi
fl
fl
fl
Two schedules are said to
Two schedules are said to
be view equivalent if the
be con ict equivalent if all
order of initial read, nal
the con icting operations
write and update
in both the schedule get
operations is the same in
executed in the same
1 both the schedules. If a
order. If a schedule is a
schedule is view
con ict equivalent to its
equivalent to its serial
serial schedule then it is
schedule then it is called
called Con ict Serializable
View Serializable
Schedule.
Schedule.

If a schedule is view If a schedule is con ict


serializable then it may or serializable then it is also
2
may not be con ict view serializable
serializable. schedule.

Con ict equivalence can View equivalence is rather


be easily achieved by dif cult to achieve as both
reordering the operations transactions should
3 of two transactions perform similar actions in
therefore, Con ict a similar manner. Thus,
Serializability is easy to View Serializability is
achieve. dif cult to achieve.
fi
fi
fl
fl
fl
fl
fl
fl
fl
fl
fi
If a transaction T1 writes a
For a transaction T1
value A that no other
writing a value A that no
transaction reads
one else reads but later
(because later some other
some other transactions
4 transactions say T2 writes
say T2 write its own value
its own value of A) W(A)
of A, W(A) cannot be
can be placed in positions
placed under positions
of the schedule where it is
where it is never read.
never read.

Example for Con ict Serializability –


Let us consider the following transaction schedule and test it for
Con ict Serializability

T1 T2 T3

R(X)

R(X)

W(Y)

W(X)

R(Y)

W(Y)
fl
fl
Now, we will list all the con icting operations. Further, we will
determine whether the schedule is con ict serializable
using Precedence Graph.
Two operations are said to be con icting if the belong to
different transaction, operate on same data and at least one of
them is a write operation.
1. R3(X) and W2(X) [ T3 -> T2 ]
2. W1(Y) and R3(Y) [ T1 -> T3 ]
3. W1(Y) and W2(Y) [ T1 -> T2 ]
4. R3(Y) and W2(Y) [ T3 -> T2 ]
Constructing the precedence graph, we see there are no cycles
in the graph. Therefore, the schedule is Con ict Serializable.

The serializable schedule is,


T1 -> T3 -> T2
fl
fl
fl
fl
Example for View Serializability –
Let us consider the following transaction schedule and test it for
View Serializability.

T1 T2 T3

R(A)

W(A)

R(A)

W(A)

W(A)

As we know that if a schedule is Con ict Serializable, then it is


View Serializable also. So rst let us check for Con ict
Serializability.
The con icting operations for this schedule are –
1. R1(A) and W2(A) [ T1 -> T2 ]
2. R1(A) and W3(A) [ T1 -> T3 ]
3. W2(A) and R3(A) [ T2 -> T3 ]
4. W2(A) and W1(A) [ T2 -> T1 ]
5. W2(A) and W3(A) [ T2 -> T3 ]
6. R3(A) and W1(A) [ T3 -> T1 ]
7. W3(A) and W1(A) [ T1 -> T3 ]
Constructing the precedence graph for con icting operations in
the schedule.
fl
fi
fl
fl
fl
As we can see that there is a cycle in the precedence graph, it
means that the given schedule is not Con ict Serializable. Now,
on checking for blind write we get that there exists a blind write
W2(A) in the given schedule. Thus, the schedule may or may
not be View Serializable.
In order to check for View Serializability, we will draw
aDependency Graph of the schedule. From the given schedule
we gather the following points :
1. T1 reads A before T2 updates A thus, T1 must execute
before T2.
2. T3 does the nal update on A thus, it must execute in the
end.
Constructing the dependency graph.
fi
fl
As there exists no cycle in the graph, we can say that the given
schedule is View Serializable.
The serializable schedule is T1 -> T2 -> T3.

You might also like