Move money between two bank accounts and you have a problem: if the system crashes after the withdrawal but before the deposit, money vanishes. Transactions exist to make such operations all-or-nothing, and ACID is the set of guarantees that makes them trustworthy.
What a transaction is
A transaction groups several database operations into a single unit that either fully succeeds or fully fails. The classic example is a transfer: debit one account, credit another. Wrapped in a transaction, both happen or neither does — there is no in-between state where the money has left one account but not arrived in the other. You begin a transaction, do the work, and commit; if anything goes wrong, you roll back.
The four ACID guarantees
- Atomicity — all operations in the transaction succeed together, or none do. No partial application.
- Consistency — a transaction moves the database from one valid state to another, respecting all rules and constraints.
- Isolation — concurrent transactions do not interfere with each other; each behaves as if it ran alone.
- Durability — once committed, the result survives crashes and power loss; it is permanently recorded.
Isolation is the subtle one
Atomicity and durability are intuitive, but isolation hides real complexity. When many transactions run at once, they can interfere in subtle ways — reading data another transaction is midway through changing, or seeing different results when re-reading the same rows. Databases offer isolation levels that trade strictness for performance, from loose (fast, but prone to anomalies) to strict (safe, but with more locking).
Why this matters even if you do not write SQL
Even with an ORM or a managed database, ACID shapes how your data behaves under concurrency and failure. Knowing that a transaction is atomic lets you reason confidently about multi-step changes. Knowing isolation is configurable explains mysterious bugs that appear only under load, when two requests touch the same data at the same time.
- A transaction makes a group of operations all-or-nothing.
- ACID: Atomicity, Consistency, Isolation, Durability.
- Isolation levels trade anomaly prevention against concurrency.
- ACID guarantees underpin correct behaviour under failure and load.
Frequently asked questions
Do NoSQL databases have ACID?
Many now offer ACID transactions, at least within a document or region, though historically NoSQL traded strict guarantees for scale and availability. Always check what a given database actually guarantees.
What happens on a rollback?
Every change made within the transaction is undone, returning the database to its state before the transaction began, as if it never ran.