Schedules and Conflict Serializability: Precedence Graphs Worked Step by Step
Turn an interleaved DBMS schedule into a precedence graph. Follow every read and write, recover the serial order, and see how one moved block creates a cycle.
KnowledgeGate Team
Exam prep & CS education

A long interleaving of r and w operations can look like a simulation exercise. The faster, reliable test is to translate only its conflicting order constraints into a graph. In the schedule below, those edges force serial order T1,T2,T3; moving T1's C block instead creates a cycle.
What a schedule preserves and what serializability asks
A transaction is an ordered program of reads, local calculations, writes, and finally a commit or abort. A schedule interleaves operations from multiple transactions while preserving the original operation order inside each transaction. A serial schedule finishes one complete transaction before starting another. A non-serial schedule overlaps them.
Conflict serializability does not ask whether a schedule is visibly serial. It asks whether the schedule preserves the same ordering constraints between conflicting operations as some serial schedule. The useful output is therefore not just yes or no. We should also recover an equivalent serial order, such as T1,T2,T3.
Review Transactions and Concurrency Control in DBMS if ACID properties and concurrent execution need a refresh. The CS Fundamentals for Exams and Placements route places this graph test inside the wider subject.
The three-part conflict test
Two operations conflict only when all three conditions hold:
They belong to different transactions.
They access the same data item.
At least one operation is a write.
Therefore, r1(X) and r2(X) do not conflict. The pairs r1(X) before w2(X), w1(X) before r2(X), and w1(X) before w2(X) do conflict.
Direction comes from schedule order. If T1's conflicting operation occurs first, add T1 -> T2. Reverse their occurrence and the edge becomes T2 -> T1. Adjacent operations on different items produce no edge.
Use this four-line scan routine:
Group operations by data item.
Discard same-transaction pairs.
Discard read-read pairs.
Direct every remaining pair from the earlier transaction to the later one.
Several conflicts may produce the same edge, but store it once. Never add a self-loop for operations from one transaction.
Conflict equivalence and the acyclic-graph theorem
Two schedules are conflict equivalent when they contain the same operations and preserve the relative order of every conflicting cross-transaction pair. Constructively, adjacent non-conflicting operations can be swapped without changing those constraints. If such swaps can gather each transaction into a serial arrangement, the original schedule is conflict serializable.
The theorem gives a direct test: a schedule is conflict serializable if and only if its precedence graph is acyclic. Create one vertex per transaction. Add an earlier-to-later edge for every conflicting pair. If the result is a directed acyclic graph, any topological ordering is an equivalent serial order.
Equal final database values alone do not prove conflict equivalence. Conversely, unequal final values are not a substitute for the graph algorithm. Conflict serializability, view serializability, and recoverability are also different properties with different tests.
Worked schedule: execute all 12 reads and writes
Start with A=100, B=40, and C=5.
T1:r1(A); A:=A+20; w1(A); r1(C); C:=C+2; w1(C).T2:r2(A); A:=2*A; w2(A); r2(B); B:=B-10; w2(B).T3:r3(B); B:=B+5; w3(B); r3(C); C:=3*C; w3(C).
Execute schedule S in order:
Step | T1 | T2 | T3 | Database value after a write |
|---|---|---|---|---|
1 |
| |||
2 |
|
| ||
3 |
| |||
4 |
|
| ||
5 |
| |||
6 |
|
| ||
7 |
| |||
8 |
|
| ||
9 |
| |||
10 |
|
| ||
11 |
| |||
12 |
|
|
T2 runs between T1's A block and C block, but every transaction keeps its own program order. Commits add no precedence edge in this basic read-write test. The exact final state is (A,B,C)=(240,35,21).
Build the precedence graph and recover the serial order
Scan A first. r1(A) before w2(A), w1(A) before r2(A), and w1(A) before w2(A) all collapse to T1 -> T2. The read-read pair adds nothing.
For B, the corresponding read-write, write-read, and write-write conflicts all give T2 -> T3. For C, they give T1 -> T3. The complete edge set is {T1 -> T2, T2 -> T3, T1 -> T3}.
Now compute the topological order:
Initially,
in(T1)=0,in(T2)=1, andin(T3)=2.Remove T1. T2's indegree becomes 0, and T3's becomes 1.
Remove T2. T3's indegree becomes 0.
Remove T3.
The unique order is T1,T2,T3. Re-executing it confirms the values: T1 makes A=120,C=7; T2 makes A=240,B=30; T3 makes B=35,C=21. This matches (240,35,21), while the acyclic graph remains the proof.
The order is unique because every transaction pair is constrained: T1 must precede T2 and T3, while T2 must precede T3. Keep T1 -> T3 in the graph even though the path through T2 already implies that order. A precedence graph records direct conflict evidence, not merely a transitive reduction.

One moved operation block creates a cycle
Create S_cycle by moving T1's complete r1(C), w1(C) block and its commit to the end. Every other relative order remains unchanged. T3 now reads C=5 and writes C=15. T1 then reads C=15 and writes C=17. A and B still finish at 240 and 35, so the new final state is (240,35,17).
Only the C edge changes. A still gives T1 -> T2, and B still gives T2 -> T3. On C, T3's conflicting operations now occur first, giving T3 -> T1. The graph contains T1 -> T2 -> T3 -> T1. Every vertex has indegree 1, so no topological removal can begin and no serial order satisfies all constraints.
Once a directed cycle is proved, stop. Name each edge and its data item: A causes T1 -> T2, B causes T2 -> T3, and C causes T3 -> T1. The fact that all transactions commit does not make the schedule conflict serializable.

Traps and the ways questions test this topic
Keep these traps separate:
Read-read is not a conflict, and different data items never conflict.
Edge direction follows schedule order, not transaction number.
One transaction pair can have edges in both directions.
Repeated conflicts do not require parallel edges.
A cycle can contain two or more vertices.
A DAG can have several valid topological orders.
For the worked schedule, the answers are: A gives T1 -> T2; B gives T2 -> T3; original C gives T1 -> T3; the serial order is T1,T2,T3; moved C gives T3 -> T1 and closes the three-vertex cycle. For the fresh schedule r1(X),r2(X), there is only a read-read pair. Its graph has two isolated vertices, so both T1,T2 and T2,T1 are valid serial orders.
Questions may ask you to identify conflicts, draw the graph, decide serializability, list topological orders, or find an operation move that creates or removes a cycle. They may also ask you to distinguish conflict from view serializability. Use DBMS Transaction MCQs: 12 Solved to practise these decisions without inventing extra rules.
The short version and the next step
Preserve program order. Keep only same-item, cross-transaction pairs containing a write. Direct each edge from earlier to later, collapse duplicates, and topologically sort. The original graph gives T1,T2,T3; moving T1's C block creates T1 -> T2 -> T3 -> T1.
For a broader CS route, use Zero to Hero, Complete CS Course. For placement-focused revision, use CS Fundamentals for Placements by Sanchit Sir. Then hide the graph, rebuild its three edges from the schedule, and solve the linked transaction questions.
Keep learning
Conflict Serializability MCQs: 12 Solved Schedule Questions
Solve 12 conflict serializability questions with precedence-graph checks, equivalent serial orders, blind-write traps and a worked lost-update trace.
Transactions and concurrency control in DBMS: ACID, schedules, serializability
Transactions in DBMS explained: ACID properties, schedules, conflict serializability with a worked precedence graph, two-phase locking, and the exam angle.
Operator Precedence Parsing: Build the Table and Parse an Expression Step by Step
Build an operator-precedence table from a grammar, then use it to trace every shift and reduction for i+i*i.
Operators and Precedence in C: Step-by-Step Tutorial with Runnable Examples
Learn how C groups arithmetic, relational, logical, bitwise, conditional, and assignment operators. Trace exact outputs and repair common expression mistakes.





