1 of 4

Your RightSignal

How databases work · 3 of 91 / 3

Transactions and ACID

The concept

Why a bank transfer never loses money halfway

A transaction is a group of database changes that succeeds or fails as one unit: either every change happens or none does. Moving £30 from Alice to Bob is two writes, take 30 from Alice and add 30 to Bob, wrapped between BEGIN and COMMIT.

ACID names four promises. Atomicity: all or nothing. Consistency: rules like "balance ≥ 0" always hold. Isolation: simultaneous transactions don't see each other's half-done work. Durability: once committed, it survives a crash.

If the server dies after debiting Alice but before crediting Bob, atomicity means that half-done debit is undone on restart. The £30 never vanishes into the gap.

What it’s forChecks that a transfer kept the bank's basic rule: money moves, it is never created or destroyed.

Σ balances before = Σ balances after

Σ balances
the total of all account balances involved in the transfer

What it givesTrue for any committed transfer; a half-applied transfer breaks it, which is why atomicity forbids one.

  1. Before: Alice 100 + Bob 50 = 150
  2. Committed: Alice 70 + Bob 80 = 150 ✓
  3. Crash halfway with no atomicity: 70 + 50 = 120 ✗