Serializability In DBMS
Serializability is the highest level of isolation in DBMS. It ensures that, although transactions may be executed concurrently (in parallel), the end result is as if the transactions were executed in some serial order (one by one). This guarantees the consistency of the database even when transactions are running simultaneously.
According to Serializability
“If a given non-serial schedule of ‘n’ transactions is equivalent to some serial schedule of ‘n’ transactions, then it is called a serializable schedule.”
|
Note:
|
Example of Serializability
Suppose there are 3 transactions (T1, T2, T3) where T1 executes first and then T2 and T3. Then, the serial schedule will contain the following series of transaction executions.
T1→T2→T3
Non-serial must contain a series where any transaction cannot repeat itself, just like the above serial schedule, but the position of the transaction can be interchanged. So, Non-serial will be one of the following if it is serializable.
- T1→T2 →T3
- T1→T3 →T2
- T2→T1 →T3
- T2→T3 →T1
- T3→T1 →T2
- T3→T2 →T1
Important: If a schedule contains a series of transactions where transactions are repeating, like T1→T2 →T1 →T3 where T1 is repeating, then that series will not be serial.
Types of Serializability
Serializability is mainly of two types

1. Conflict Serializability:
-
A schedule (a sequence of operations from multiple transactions) is conflict-serializable if it can be transformed into a serial schedule by swapping non-conflicting operations.
-
Conflicting operations are those that:
-
Belong to different transactions.
-
Access the same data item.
-
At least one of them is a write operation.
-
-
If conflicting operations can be reordered to form a serial schedule, the schedule is considered conflict serializable.
Example of Conflict Serializability
Let’s say we have two transactions, T1 and T2, which perform operations on the same data item X:
-
T1: Write(X)
-
T2: Read(X), Write(X)
The schedule with these operations might look like this:
-
T1: Write(X)
-
T2: Read(X)
-
T2: Write(X)
In this case, there is a conflict between T1’s Write and T2’s Write, because both are trying to modify X. We can swap the operations to create a serial schedule, for example:
-
T2: Read(X)
-
T1: Write(X)
-
T2: Write(X)
This schedule is conflict-serializable, as it can be rearranged to form a serial order.
2. View Serializability:
-
A schedule is view serializable if it is equivalent to a serial schedule in terms of the final results (i.e., it preserves the final state of the database).
-
Unlike conflict serializability, which focuses on conflicting operations, view serializability is concerned with whether the transactions observe the same initial values and produce the same final values, even if the operations are ordered differently.
While conflict serializability is a stricter condition, view serializability allows more flexible execution but is harder to implement efficiently.
How is Serializability Implemented?
Locking Mechanisms:
-
Two-Phase Locking (2PL): Ensures that once a transaction releases a lock, it cannot request any more locks, preventing conflicting operations.
-
Strict Two-Phase Locking: A stricter version of 2PL, where a transaction must hold all its locks until it commits, ensuring serializability.
Timestamp Ordering:
-
Transactions are given timestamps. The DBMS ensures that transactions are executed in timestamp order, ensuring that transactions behave in a serializable way.
Serializable Schedules:
-
The DBMS uses algorithms to generate serializable schedules, ensuring transactions do not violate serializability.
Conclusion
Serializability is a critical concept in DBMS for ensuring that concurrent transactions don’t lead to inconsistencies in the database. By ensuring that the result of executing transactions concurrently is the same as if they had been executed sequentially, serializability helps maintain the integrity and consistency of the database while allowing for efficient multi-user access. Conflict serializability is the most commonly used approach in practice to enforce this property.