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

Difference between Con ict and View

Serializability

Prerequisite – Types of Schedules in DBMS


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)
fi
fl
W(X)

Now, let
us gure
out if the
above
schedule
is
serializabl
e.

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

Swapping
R(X)
of T1
and
W(Y
) of
T2.
fi
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
serializabl
e.

Types of
Serializab
le
Schedules
:

1.
Result
Equi
valen
t
Sche2
fl
Con ict
Equi
valen
t
Sche
dule
or
Con
ict
Seria
lizabi
lity

3
View
Equi
valen
t
Sche
dule
or
View
Seria
lizabi
lity
f
fl
Differenc
e between
Con ict
and View
Serializab
ility :

S.No. Con ict View


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

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

Con ict equivalence View equivalence is


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

Example
for
Con ict
Serializab
ility –

Let us
consider
the
following
transaction
schedule
and test it
for
Con ict
Serializabi
lity
fl
fl
Now, we
will list all
the
con icting
operations
. Further,
we will
determine
whether
the
schedule
is con ict
serializabl
e using
Precedenc
e 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.
fl
fl
fl
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

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 ]
fl
fi
fl
fl
Constructing the precedence graph for con icting operations in the
schedule.

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
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