← back to databases

Transactions

Wikipedia · wpDatabase transaction · CC BY-SA 4.0

A transaction is a sequence of operations that either all succeed (commit) or all fail (rollback). The ACID properties guarantee correctness: Atomicity (all or nothing), Consistency (valid state to valid state), Isolation (concurrent transactions do not interfere), Durability (committed data survives crashes).

time T1 R(A) W(A) Commit T2 R(A) W(A) conflict T1 writes A, T2 reads A: a write-read conflict.

ACID properties

Atomicity: a transaction is indivisible. If any operation fails, all are undone. Consistency: the database moves from one valid state to another. Isolation: concurrent transactions behave as if they ran serially. Durability: once committed, the data persists even through power failures.

Scheme

Serializability and conflict graphs

A schedule is serializable if its result equals some serial execution of the same transactions. To test: build a conflict graph (precedence graph). Add an edge T1 -> T2 whenever T1 and T2 access the same item and at least one writes, and T1 goes first. If the graph has no cycle, the schedule is conflict-serializable.

Scheme
Neighbors

Cross-references

  • 🖥 OS Ch.4 — synchronization: transactions are the database equivalent of critical sections and mutual exclusion

Foundations (Wikipedia)