Table of Contents
ACID describes four properties of database transactions: atomicity, consistency, isolation, and durability. Together they describe what happens when several changes must succeed as one unit, when transactions overlap, and when the database restarts after a failure.

The four ACID properties with a transfer example
| Property | What it means | Example |
|---|---|---|
| Atomicity | The transaction commits as a unit or its effects are rolled back. | The debit and credit both commit. A failure before commit leaves neither change in place. |
| Consistency | A successful transaction preserves the rules the system enforces. | A check constraint rejects a balance below the allowed minimum. The application must still choose the correct account and amount. |
| Isolation | The isolation level determines how concurrent transactions can observe or affect one another. | Two transfers from the same account cannot safely rely on the same old balance without appropriate concurrency control. |
| Durability | A committed transaction survives failures covered by the database’s durability guarantees. | After a crash and recovery, a transfer the database durably committed is still present. |
Put the guarantee in the right place
Put related database writes between BEGIN and COMMIT. Check the input and affected rows before committing, and roll back on failure. Use constraints for rules the database can enforce, such as unique IDs and foreign keys. A message sent to an outside service is a separate effect unless you design a way to coordinate it with the transaction.
The usual SQL isolation level names are Read Uncommitted, Read Committed, Repeatable Read, and Serializable. The details vary by database. Serializable aims for the results of some one-at-a-time ordering and may reject a transaction that must be retried. See PostgreSQL’s isolation guide for a concrete implementation.
Durability depends on storage and configuration. For example, an asynchronous commit mode can have different recovery guarantees. Backups still matter for accidental deletion or storage loss.
ACID and eventual consistency can coexist

An order can commit in one database while a separate search index updates later. The order’s transaction and the delay before it appears in search describe different parts of the system. A pattern such as CQRS separates read and write responsibilities and does not determine the guarantees by itself.
Try the SQL learning path for transaction practice, then use the database practices lab to test what happens when a transaction boundary or constraint is wrong.
Reader Comments 0
Sign in with email or Google to join the discussion.