Tech●●●●●Difficulty 3 of 5

Why doesn't money vanish when two bank transfers happen at once?

The name ACID was coined in 1983, and its opposite, BASE, was named on purpose to be its chemical counterpart.

▶ Start the story

Money doesn't vanish because the database treats a transfer as one indivisible unit of work, called a , and follows four rules known as ACID. A bank transfer has two steps: take money from one account, add it to another. If the machine crashed between them, or a second transfer sneaked in halfway, the numbers could end up wrong. ACID is the promise that this never happens.

Atomicity says a either succeeds completely or fails completely. If any step fails, the whole thing fails and the database is left unchanged, so the money can't leave account A without arriving in account B. Consistency says a transaction can only take the database from one valid state to another, respecting its rules. Durability says that once a transaction is committed, it stays committed even through a crash or power cut. To keep that promise, many databases write the change into a log on safe storage first, before touching the data itself.

The four ACID promises
  1. Step 1: Atomicity

    All steps happen, or none do

  2. Step 2: Consistency

    Only valid states, rules kept

  3. Step 3: Isolation

    Concurrent work acts like one at a time

  4. Step 4: Durability

    Committed means it stays, even after a crash

The rule that covers two transfers at once is isolation. At its strictest, running transactions concurrently must leave the database in the same state as if they had run one after another. Without it you can get problems such as a , where one reads a row that another has changed but not yet committed, and might yet cancel.

Theo Härder and Andreas Reuter coined the acronym in 1983, building on Jim Gray's earlier work. The idea was already running in IBM's IMS in 1973.

Quiz me

0/3

  1. 1.Which ACID property stops two simultaneous transfers from interfering with each other?
  2. 2.What does atomicity guarantee about a bank transfer?
  3. 3.How does write-ahead logging help after a power failure?

Recap

A transaction is all-or-nothing, valid, run as if one at a time, and permanent once committed.

💡 A trick to remember it · All or nothing, rules kept, one at a time, written in stone: A, C, I, D.

Surprising fact · IBM IMS had ACID transactions in 1973, ten years before the acronym was coined.

Sources (3)

No source, no claim. Every fact in this lesson (13 claims) cites at least one of these.

  1. [1]ACID · Wikipedia
  2. [2]Isolation (database systems) · Wikipedia
  3. [3]Write-ahead logging · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗