CSC265 ยท 2076 ยท 5 marks
Define schedule and serializability. How can you test the serializability?
Define schedule and serializability. How can you test the serializability? [5]
Quick answer
A schedule (also called a history) is an ordering of the operations from a set of concurrent transactions, where the operations of each individual transaction appear in the same order as they do in that transaction. A schedule defines the sequence in which operations (read, write, commit, abort) from multiple transactions are interleaved and executed by the DBMS.
Schedule and Serializability
Schedule
Example: If T1 and T2 are two transactions, a possible schedule S could be:
S: R1(X) โ R2(X) โ W1(X) โ W2(X)
Serializability
A concurrent schedule is said to be serializable if its final result (effect on the database) is totally the same as the final result produced by some serial schedule (where transactions execute one after another without interleaving).
Since serial schedules are always considered correct (no concurrency issues), any serializable schedule is also considered correct.
There are two types of serializable schedules:
1. Conflict Serializable
A schedule is conflict serializable if it can be transformed into a serial schedule by swapping non-conflicting operations.
2. View Serializable
A schedule is called view serializable if its view equals that of a serial schedule (no overlapping transactions). A conflict serializable schedule is always view serializable, but if the schedule contains blind writes, it may be view serializable without being conflict serializable.
Testing for Serializability (Precedence Graph Method)
The most common method to test conflict serializability uses a Precedence Graph (also called a serialization graph).
Algorithm:
- Look at only
read_Item(X)andwrite_Item(X)operations in the schedule. - Construct a precedence graph -- a directed graph where each transaction Ti is a node.
- Draw a directed edge from Ti to Tj if one of the operations in Ti appears before a conflicting operation in Tj. Two operations conflict if:
- They belong to different transactions
- They access the same data item X
- At least one of them is a write
- The schedule is conflict serializable if and only if the precedence graph has NO cycles.
Example:
Consider Schedule S with transactions T1 and T2:
S: R1(X) โ W2(X) โ W1(X) โ R2(Y) โ W2(Y)
| Conflict Detected | Edge |
|---|---|
| R1(X) before W2(X) | T1 โ T2 |
| W2(X) before W1(X) | T2 โ T1 |
Precedence Graph:
T1 -----> T2
T2 -----> T1 (CYCLE EXISTS)
Since a cycle exists, this schedule is NOT conflict serializable.
Summary Table
| Property | Meaning |
|---|---|
| Serial Schedule | Transactions execute one after another (always correct) |
| Serializable Schedule | Equivalent in result to some serial schedule |
| Test Method | Precedence graph -- no cycle = serializable |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.