ACID Explained: How Databases Keep Their Promises

ACID explained in plain terms means understanding the four promises a database makes about every transaction, so that money never vanishes, bookings never double, and a crash never leaves the data half changed. The central question is how a system that juggles thousands of simultaneous operations can still be trusted with the facts that matter, and the answer is a set of guarantees that turn a bundle of changes into a single, indivisible act.

ACID is an acronym for atomicity, consistency, isolation, and durability, four properties that define a database transaction. A transaction is a group of operations that must succeed together or fail together, such as moving money from one account to another, and ACID is the contract that says the database will treat that group as one unit, however busy or unreliable the world around it is.

The idea is simple: never leave the data in a state that could not have happened. Either the whole transaction is visible, as if it happened in one instant, or none of it is, as if it never happened at all, and once the database says a transaction is done, it stays done, even if the power fails a second later. This article explains what ACID is, how it works, and where it is used.

Key takeaways

  • ACID stands for atomicity, consistency, isolation, and durability.
  • Atomicity means a transaction succeeds completely or not at all.
  • Consistency means the data always obeys the rules after a transaction.
  • Isolation means concurrent transactions cannot see each other’s half-finished work.
  • Durability means a committed transaction survives a crash.

What ACID is

Atomicity is the all-or-nothing promise. A transaction that moves money debits one account and credits another, and atomicity says both changes happen, or neither does, even if the server crashes between them. If anything fails partway through, the database rolls the transaction back, undoing every change it made, so the data looks exactly as it did before the transaction began.

Consistency is the promise that the data always obeys its rules. A database has constraints, such as an account balance that cannot go below zero, or an order that must belong to a customer, and consistency says a transaction may only move the data from one valid state to another. A transaction that would break a rule is rejected outright, rather than being allowed to leave the data broken.

Isolation is the promise that concurrent transactions do not interfere with each other. When two transactions run at the same time, each must behave as if it ran alone, in some order, even though they really overlap, which stops one transaction from reading another’s half-finished changes, or overwriting work it never saw. Our guide to SQL explains the language transactions are written in, and our guide to distributed systems explains the harder problem of keeping these promises across many machines.

How ACID works

Atomicity is usually implemented with a write-ahead log. Before a change touches the data, it is written to a log on disk, and only then is the data itself updated. If the system crashes, the database replays the log on restart: transactions that were fully logged are redone, and transactions that were only partly logged are undone, so the data always ends in a state the log can account for.

Consistency is enforced by the database itself, through constraints, triggers, and the rules of the schema. A foreign key stops an order pointing at a customer that does not exist, a check constraint stops a negative balance, and a unique constraint stops two users registering the same email address. The transaction is the unit that these rules are checked against, so no single statement can leave the data in a state the rules forbid.

Isolation is implemented with locking, or with multi-version concurrency control. Locking makes a transaction hold exclusive locks on the rows it changes, so others must wait, while multi-version control keeps old copies of rows around, so a reader sees a consistent snapshot from the moment its transaction began, without blocking writers. Each approach trades throughput against simplicity.

Isolation is not one level but several, defined by the SQL standard. Read committed lets a transaction see only changes that are already committed, repeatable read guarantees the same read returns the same result throughout a transaction, and serializable, the strictest level, makes concurrent transactions behave exactly as if they ran one after another. Stronger levels cost more, because they block or abort more often.

Durability is the promise that a committed transaction is permanent. When a database reports a transaction as committed, it has already written the change to durable storage, usually by forcing the write-ahead log to disk before replying, so that a power failure, a crash, or a reboot cannot lose it. That forced write is the main cost of durability, and it is why fast disks and battery-backed caches matter to database performance.

A laptop on a dark desk with its screen showing a glowing green ledger with a transaction stamped as complete
A laptop showing a glowing green ledger with a transaction stamped as complete shows how ACID works: all or nothing, then written for good.

Comparing ACID with other guarantees

ACID is one of several sets of guarantees a system can offer, and each suits a different need. BASE trades guarantees for scale, eventual consistency lets replicas catch up over time, and a single-user file needs no guarantees at all, but each has its own trade-offs.

The table below sets out the main contrasts between the leading approaches.

Aspect ACID BASE Eventual consistency
Guarantee All or nothing, always Best effort, later Converges over time
Reads after write See the new value at once May see the old value May see the old value
Use case Money, bookings Feeds, analytics Caches, replicas
Cost Slower, more locking Faster, simpler Fastest, least coordination
Best for Correctness first Scale first Availability first

The practical result is that ACID is the right choice when correctness cannot be compromised, BASE wins when scale matters more than instant agreement, and eventual consistency is the choice for caches and replicas where availability comes first.

Where ACID is used

Banking is the classic use. A transfer must debit one account and credit another as a single act, and ACID is what stops the money from disappearing if the system fails between the two steps, or from being counted twice if the operation is retried. Every core banking system is built on ACID transactions.

Booking systems use ACID to stop double selling. A seat, a room, or a ticket is reserved inside a transaction that checks availability and records the booking together, so that two customers asking at the same moment cannot both succeed, and a crashed booking leaves the seat free rather than half sold.

E-commerce uses ACID to keep orders consistent. Placing an order reduces stock, records the payment, and creates the shipment as one transaction, so that a failure cannot leave a customer charged for an order that was never recorded, or stock reduced for an order that was never paid for.

Healthcare uses ACID to protect patient records. A prescription, a lab result, and a diagnosis are recorded together, and the guarantees mean a record is never half written, which matters when a later reader, a doctor or a pharmacist, must trust that what they see is complete.

Any system that keeps money, inventory, or legal records uses ACID somewhere. Even systems that are mostly eventually consistent keep their critical writes, such as payments and ownership changes, inside ACID transactions, and let the looser guarantees apply only to the data that can safely lag behind.

Strengths and limits

The greatest strength of ACID is trust. A developer can reason about a transaction as if it happened alone, in one instant, and never worry about crashes, retries, or concurrent users corrupting the data, which makes correct programs far easier to write than they would be on a system that offers weaker guarantees.

It is also a strength that ACID is a standard. Every relational database offers it, the isolation levels are defined by SQL, and decades of practice have made the guarantees well understood, which is why regulated industries and financial systems still insist on it.

The limits are real, though. ACID costs performance, because locking blocks concurrent work, forced writes to disk are slow, and the guarantees are hard to keep across many machines, which is why distributed systems often relax them. When scale matters more than instant correctness, BASE and eventual consistency are the pragmatic choice.

ACID checklist

  • Keep transactions short, so locks are held briefly.
  • Put everything that must succeed together inside one transaction.
  • Use the weakest isolation level your correctness allows.
  • Never do slow work, such as network calls, inside a transaction.
  • Handle retries, since a serializable transaction can be aborted.
  • Check constraints in the database, not only in the application.
  • Test what happens when the power fails mid-transaction.
  • Monitor lock waits, since they are the first sign of trouble.
  • Back up the write-ahead log as well as the data itself.

Frequently asked questions

What is ACID in simple terms?

ACID is four promises a database makes about a transaction: it happens completely or not at all, it leaves the data obeying the rules, it is hidden from other transactions until it is done, and once it is done, it stays done even after a crash.

What is atomicity?

It is the all-or-nothing promise. All the operations in a transaction succeed together, or all of them are undone, so the data is never left half changed, even if the system fails in the middle of the transaction.

What is the difference between isolation levels?

They are grades of how strictly concurrent transactions are kept apart. Read committed is the loosest, repeatable read is stricter, and serializable is the strictest, making transactions behave as if they ran one after another, at the cost of speed.

What is a write-ahead log?

It is a log on disk where every change is recorded before it touches the data. If the system crashes, the database replays the log to redo committed work and undo incomplete work, which is how atomicity and durability are implemented.

What is BASE, and how does it differ from ACID?

BASE stands for basically available, soft state, and eventually consistent. It is the looser set of guarantees used by systems that prioritise scale and availability over instant correctness, accepting that replicas may disagree briefly.

When should I not use ACID?

When the data can safely be approximate, when the system must stay available during a network partition, or when the scale makes locking too expensive. Feeds, analytics, and caches are the usual cases where weaker guarantees are the right trade.

The bottom line

ACID explained in one line is this: a transaction is one indivisible act, hidden from others until it is done, obeying every rule, and permanent once it is committed.

It is the contract that makes databases trustworthy, and it remains the foundation of every system where a lost or half-finished change would cost real money, or real harm.

This article is general information about how ACID works, not advice about designing transactions for a particular system.

Latest articles

Scroll to Top