ACID Database Properties
Download image
Core guarantees for reliable database transactions
A database transaction groups one or more read or write operations into a single unit of work. A bank transfer, for example, groups the debit from one account and the credit to another. ACID describes four properties that keep those operations reliable when a step fails, several transactions run at once, or a server crashes.
On this page
Atomicity — All or Nothing
Atomicity treats a transaction as an indivisible unit. The database commits all its transactional changes together or discards them together.
- Core guarantee. A failed transfer cannot leave the sender’s balance reduced with no corresponding credit to the recipient.
- Mechanism. If the transaction cannot complete or is explicitly cancelled with
ROLLBACK, the database discards its uncommitted changes. How rollback works internally depends on the engine.
Consistency — Valid State Transitions
A successful transaction takes the database from one valid state to another. The committed data must satisfy the rules defined for it.
- Core guarantee. For example, a
CHECKconstraint can require each account balance to stay at or above zero. - Mechanism. The database enforces rules such as column types, uniqueness, foreign keys, and check constraints. Some rules are checked at the end of each statement, and deferrable constraints can be checked at commit. The transaction also needs to implement business rules, such as debiting and crediting the same amount.
Isolation — Independent Execution
Isolation controls what transactions can see and how they can affect one another when they run concurrently. In PostgreSQL, another transaction cannot read an uncommitted debit during the transfer.
- Core guarantee. At the
SERIALIZABLElevel, successfully committed transactions produce the same result as running them one at a time in some order. - Mechanism. Database engines coordinate concurrent work with techniques such as two-phase locking or multi-version concurrency control (MVCC). MVCC lets queries read a snapshot of the data.
- Performance trade-off. Isolation levels differ in the anomalies they prevent, such as dirty reads, non-repeatable reads, phantom reads, and serialization anomalies. Stricter levels can require additional coordination or cause transactions to retry.
Durability — Permanent Storage
Once the database confirms a durable commit, the changes survive a crash, restart, or power loss.
- Core guarantee. If the server crashes after confirming a durable commit, the completed transfer stays recorded even though the data in memory is lost.
- Mechanism. With PostgreSQL’s default durability settings, it writes the required write-ahead log (WAL) records to durable storage before confirming the commit. After a crash, PostgreSQL can replay the WAL to recover changes that had yet to reach the data files.
Summary of Guarantees
| Property | Focus | Primary protection |
|---|---|---|
| Atomicity | Completeness | Prevents a partial transaction from being committed |
| Consistency | Validity | Keeps committed data within defined rules |
| Isolation | Concurrency | Controls interactions between concurrent transactions |
| Durability | Persistence | Preserves committed changes across crashes |
Relational systems such as PostgreSQL support ACID transactions. In distributed systems, check which operations can share a transaction, which isolation levels are available, and how quickly replicas reflect committed writes. These guarantees vary by engine and configuration.