Home / Learn Secure SQL / ACID: the Four Guarantees of a Transaction

ACID: the Four Guarantees of a Transaction

Atomicity, Consistency, Isolation, Durability.

In shortAtomicity, Consistency, Isolation, Durability.

What's actually going on

Four lettersAtomicity: all ornothingConsistency: rulesalways holdIsolation:transactions do not…Durability: committeddata survives a crash
Four letters

The basic idea

ACID describes four guarantees a proper transaction gives you: all-or-nothing, rules always hold, transactions do not interfere with each other, and committed data survives a crash.

Why this comes up

Knowing these guarantees lets you reason precisely about what can and cannot go wrong when several requests touch the database at once.

The mechanics

Wrap related changes in a transaction and trust the database to provide all four guarantees for you.

Where it is used

  • Web application code review
  • Backend development
  • Database administration
LetterGuaranteeEveryday example
AAtomicityA money transfer either fully happens or not at all
CConsistencyA CHECK constraint is never violated, even mid-crash
IIsolationTwo concurrent transfers do not corrupt each other's math
DDurabilityOnce COMMIT returns, the change survives a power cut

Quick check

1. ACID is a set of guarantees about...