What is conflict serializability in SQL ?
Overview
Serializability is bascially used to ensure that transactions are executing in a correct way without any interruption.
-
Serializability allows the database to be in a consistent state.
-
Serializability is generally used in the transactions.
Serializability is of two types:
- Conflict serializability
- View serializability
Conflict serializability occurs when two instructions conflict for a single data item.
There will be no conflict if we read the data, but there will be a conflict if we write the data.
Instructions O i and O j are the transactions of Ti and Tj respectively. Then there exists a conflict if some item Q accessed by both O i and O j. At least one of these instructions writes Q.
-
O i = read(Q), O j = read(Q). O i and O j don’t conflict.
-
O i = read(Q), O j = write(Q). They conflict.
-
O i = write(Q), O j = read(Q). They conflict.
-
O i = write(Q), O j = write(Q). They conflict.
If a schedule S can be converted into a schedule S ´ by a series of swaps of non-conflicting instructions, we say that S and S ´ conflict equivalent.
S
T1 | T2 |
Read(A) | |
Write(A) | |
Read(A) | |
Write(A) | |
Read(B) | |
Write(B) | |
Read(B) | |
Write(B) |
S'
T1 | T2 |
Read(A) | |
Write(A) | |
Read(B) | |
Write(B) | |
Read(A) | |
Write(A) | |
Read(B) | |
Write(B) |
-
Here S and S’ are conflict equivalent.
-
The order of each pair of conflicting operations in S and S` is the same.