0
0
DBMS Theoryknowledge~6 mins

Conflict serializability in DBMS Theory - Full Explanation

Choose your learning style9 modes available
Introduction
When multiple transactions run at the same time in a database, their operations can mix up and cause wrong results. We need a way to check if the mixed operations still behave like some order of running transactions one after another.
Explanation
Transactions and Conflicts
Transactions are sequences of database operations like reading or writing data. Conflicts happen when two operations from different transactions access the same data and at least one is a write. These conflicts can change the final result depending on the order of operations.
Conflicts occur when transactions try to read or write the same data and at least one writes.
Serial Schedule
A serial schedule runs transactions one after another without overlapping. This means no two transactions run at the same time. Serial schedules are easy to understand because the order of transactions is clear and predictable.
Serial schedules run transactions one by one, avoiding any overlap.
Conflict Serializability
A schedule is conflict serializable if it can be changed by swapping non-conflicting operations to become a serial schedule. This means even if transactions run together, their effect is the same as if they ran one after another in some order.
Conflict serializability ensures a mixed schedule behaves like some serial schedule.
Precedence Graph
A precedence graph shows transactions as nodes and conflicts as directed edges. If the graph has no cycles, the schedule is conflict serializable. Cycles mean conflicts that cannot be reordered to a serial schedule.
A cycle-free precedence graph means the schedule is conflict serializable.
Real World Analogy

Imagine two cooks sharing a kitchen. They both need to use the same knife and cutting board. If they take turns using these tools without interrupting each other, the cooking process is smooth and predictable. But if they try to use the knife at the same time, it causes confusion and mistakes.

Transactions and Conflicts → Two cooks trying to use the same kitchen tools at the same time
Serial Schedule → Cooks taking turns using the knife and cutting board one after another
Conflict Serializability → Even if cooks work together, their actions can be rearranged to look like they took turns
Precedence Graph → A chart showing which cook needs to wait for the other to finish using a tool
Diagram
Diagram
┌─────────────┐       ┌─────────────┐
│ Transaction │─────▶ │ Transaction │
│     T1      │       │     T2      │
└─────────────┘       └─────────────┘
       ▲                     │
       │                     ▼
┌─────────────┐       ┌─────────────┐
│ Transaction │◀───── │ Transaction │
│     T3      │       │     T4      │
└─────────────┘       └─────────────┘

If no cycles exist in this graph, the schedule is conflict serializable.
This precedence graph shows transactions as nodes and conflict edges; absence of cycles means conflict serializability.
Key Facts
ConflictTwo operations conflict if they access the same data and at least one is a write.
Serial ScheduleA schedule where transactions run one after another without overlapping.
Conflict Serializable ScheduleA schedule that can be transformed into a serial schedule by swapping non-conflicting operations.
Precedence GraphA directed graph representing conflicts between transactions to check serializability.
Cycle in Precedence GraphIndicates the schedule is not conflict serializable.
Common Confusions
Believing all serializable schedules are conflict serializable.
Believing all serializable schedules are conflict serializable. Some schedules are serializable by other methods but not conflict serializable; conflict serializability is a stricter condition.
Thinking any overlapping schedule is incorrect.
Thinking any overlapping schedule is incorrect. Overlapping schedules can be correct if they are conflict serializable and produce the same result as some serial order.
Summary
Conflict serializability helps ensure that concurrent transactions produce correct results by behaving like some serial order.
It uses conflicts between operations and a precedence graph to check if a schedule can be rearranged safely.
Schedules without cycles in their precedence graph are conflict serializable and thus safe to run concurrently.