school DBMS Core Fundamentals

Conflict Serializability

The gold standard for consistency in concurrent transactions. Learn how databases ensure data integrity when multiple users access the same data simultaneously.

Traffic Intersection Analogy

The Real World Analogy

Imagine a busy intersection (the Database). Vehicles (Transactions) want to cross. Serializability is like a traffic light: one road goes, then the other. Safe, but slow. Conflict Serializability is like a smart roundabout: cars weave through simultaneously efficiently, but strict rules prevent crashes (Conflicts).

menu_book Technical Definition

Conflict Serializability is a property of a schedule (a sequence of operations from multiple transactions) that guarantees the final state of the database is consistent, equivalent to some serial execution of the transactions.

A schedule is Conflict Serializable if it can be transformed into a serial schedule by swapping non-conflicting adjacent operations.

The Golden Rule of Conflict

Two operations Oi and Oj are said to be in conflict if and only if they satisfy ALL three conditions:

  1. They belong to different transactions (e.g., T1 and T2).
  2. They access the same data item (e.g., both access A).
  3. At least one of them is a Write operation.

Conflict Types (The "Bad" Pairs)

  • RW Read-Write

    Unrepeatable Read

  • WR Write-Read

    Dirty Read

  • WW Write-Write

    Blind Write / Overwrite

Visualizing Conflicts

Data Item: A T1 Read(A) T2 Write(A) CONFLICT! T1 reads A before T2 writes A Ordering matters!

Precedence Graph Interactive Lab

The standard test for conflict serializability is building a Precedence Graph. If the graph has a Cycle, the schedule is NOT serializable. If it has No Cycle (DAG), it IS serializable.

list_alt Schedule Operations

Select a scenario above to start...

Step through operations to find conflicts.

hub Precedence Graph

Graph will appear here
cancel Cycle Detected! Not Conflict Serializable

psychology Interview Cheat Sheet

Q: Why do we care about Conflict Serializability? expand_more
It provides a practical way to ensure database consistency in concurrent environments without forcing transactions to run one after another (which is slow). If a schedule is conflict serializable, the database system guarantees the data stays correct, even if operations are interleaved for performance.
Q: What is the Precedence Graph method? expand_more

It's an algorithm to test for conflict serializability:

  • Create a node for each committed transaction.
  • Draw an edge Ti → Tj if an operation in Ti conflicts with and precedes an operation in Tj.
  • If the graph has a cycle, it is NOT conflict serializable.
  • If there is no cycle, a topological sort gives the equivalent serial order.
Q: Is every Serializable schedule Conflict Serializable? expand_more

NO.

Conflict Serializability is a subset of View Serializability (and general Serializability). There are schedules (like "Blind Writes") that are View Serializable but NOT Conflict Serializable. However, Conflict Serializability is the one most databases actually implement (via Two-Phase Locking or Timestamp Ordering) because it's computationally cheaper to check (O(N2)) compared to View Serializability (NP-Complete).