Database Engines & ACID Properties: Concept
Module: Foundational Concepts
ACID is not a list of features — it is a set of guarantees that collectively ensure a database never leaves data in a corrupt intermediate state, no matter what goes wrong. Each property targets a specific failure mode: Atomicity blocks partial writes, Consistency enforces business rules, Isolation prevents concurrent interference, and Durability makes commits permanent even through crashes. Together they let you write multi-step operations — transfers, checkouts, reservations — and trust the result is always correct.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
A — ATOMICITY: All or Nothing
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
A transaction is indivisible. Either every statement commits
or none of them do. There is no in-between visible state.
BEGIN TRANSACTION
│
Step 1 ──► Step 2 ──► Step 3
│ │ │
OK ✓ OK ✓ FAIL ✗
│
ROLLBACK ↩
┌───────────────────────────┐
│ DB is back to pre-tx state │
│ as if nothing happened │
└───────────────────────────┘
Mechanism: The database engine writes every change to an
undo log before applying it. On failure, it reads the undo
log backwards and reverts each row to its original value.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
C — CONSISTENCY: Valid State → Valid State
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Every transaction must leave the database in a state that
satisfies all defined constraints (PK, FK, CHECK, NOT NULL,
triggers, and application-level invariants).
BEFORE TX: AFTER TX (COMMIT):
┌─────────────────────┐ ┌─────────────────────┐
│ acc A: balance=500 │ ─────► │ acc A: balance=400 │
│ acc B: balance=200 │ │ acc B: balance=300 │
│ CHECK (balance >= 0)│ │ CHECK still holds ✓ │
└─────────────────────┘ └─────────────────────┘
Total = 700 Total = 700 ← invariant
If a transfer would violate CHECK (balance >= 0):
┌─────────────────────┐
│ acc A: balance=500 │ ─────► ROLLBACK (constraint
│ Transfer: -600 │ violated, state unchanged)
└─────────────────────┘
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
I — ISOLATION: Concurrent Transactions Don't Interfere