Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Explain each letter of ACID for a relational database and give, for each one, a concrete example of what goes wrong in a money transfer between two accounts if that property is missing.

ACID is four guarantees a transaction gives. Atomicity means the debit and the credit both happen or neither does, so a crash between them cannot lose money. Consistency means each transaction moves the database from one valid state to another as defined by constraints such as CHECK (balance >= 0), plus invariants the application owns. Isolation means concurrent transfers do not see each other's partial work, to the degree the isolation level promises, and durability means that once COMMIT returns, the transfer survives a crash because its log record was flushed to disk.

Why this question is asked

ACID is often recited as four words, but interviewers want to know whether we understand what each property protects us from and how the database actually provides it. A money transfer is the perfect example, because each missing property produces a different, very concrete bug. In this answer, we will set up the transfer, then go through atomicity, consistency, isolation and durability one by one, each time with what goes wrong without it and how the database implements it, and finish with how the C in ACID differs from the C in CAP.

1The Transfer We Will Use

A transaction is a group of statements that the database treats as one unit of work. Our example moves 100 from account A, which holds 500, to account B, which holds 200. It is two updates inside one transaction.

Java
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 'A'; -- A: 500 -> 400
UPDATE accounts SET balance = balance + 100 WHERE id = 'B'; -- B: 200 -> 300
COMMIT; -- total still 700

The total amount of money, 700, must be the same before and after. Each ACID property protects that rule against a different kind of failure.

2Atomicity: All or Nothing

Atomicity means the transaction happens completely or not at all. Without it, imagine the server crashes right after the first update. A has lost 100, B never received it, and the bank has silently destroyed money.

With atomicity, a crash before COMMIT means the whole transaction is undone. Databases implement this in different ways. InnoDB in MySQL keeps undo information, the old values, and uses it to roll back unfinished changes during recovery. PostgreSQL uses MVCC, multi-version concurrency control: an update writes a new row version marked with the transaction's id, and if that transaction never commits, the new versions are simply never visible to anyone, so A still shows 500. ROLLBACK, explicit or after an error, uses the same mechanisms.

3Consistency: Valid State to Valid State

Consistency means a transaction takes the database from one valid state to another, where valid is defined by rules. Some rules the database can enforce itself: constraints such as a CHECK that a balance never goes negative, foreign keys that every transfer refers to an existing account, and uniqueness.

SQL
ALTER TABLE accounts ADD CONSTRAINT balance_not_negative CHECK (balance >= 0);
UPDATE accounts SET balance = balance - 900 WHERE id = 'A';
-- ERROR: new row for relation "accounts" violates check constraint "balance_not_negative"
-- the transaction fails, and nothing changes

Without such a rule, a transfer of 900 from A would leave A at minus 400, a state the business says must never exist. Notice the important point: the database only knows the rules we declare. The rule that a transfer must debit and credit the same amount, so the total stays 700, is an invariant the application owns. If our code credited 1,000 instead of 100, the database would commit it happily. So consistency is a shared responsibility: the database enforces declared constraints, and the application writes correct transactions.

4Isolation: Concurrent Transfers Do Not Interfere

Isolation means transactions running at the same time do not see each other's partial work. Without it, two transfers out of A could each read the balance 500, each subtract 100 and each write 400. Both commit, 200 has left the account, and A shows 400 instead of 300. This is a lost update.

ACID through one transfer
PropertyWithout itHow the database provides it
Atomicitycrash after debit: 100 disappearsundo logs (InnoDB) or MVCC versions + rollback
Consistencybalance becomes -400constraints; the application keeps its own invariants
Isolationtwo transfers both read 500: lost updatelocks, MVCC snapshots, isolation level
Durabilitycommit acknowledged, then lost in a crashWAL flushed with fsync before commit returns

How much isolation we get depends on the isolation level. READ COMMITTED, the default in PostgreSQL, prevents seeing uncommitted data. REPEATABLE READ and SERIALIZABLE prevent more anomalies, with SERIALIZABLE making the result equal to some order of running the transactions one at a time. Our UPDATE balance = balance - 100 is safe even at READ COMMITTED, because the second update waits for the first and then re-reads the committed row, but a read-then-write in application code needs locking with SELECT ... FOR UPDATE or a stricter level.

5Durability: Committed Means Kept

Durability means that once COMMIT has returned, the transfer survives a crash or power loss. Without it, the customer sees 'transfer complete', the server loses power a second later, and after restart the transfer has vanished.

Databases do not write every changed data page to disk at commit, which would be slow. Instead they write a record of the change to a sequential log, the write-ahead log in PostgreSQL or the redo log in InnoDB, and flush that log to stable storage with fsync before acknowledging the commit. After a crash, recovery replays the log to bring the data files up to date. Settings that skip or delay the flush, such as synchronous_commit = off, trade a small window of durability for speed.

6The C in ACID Is Not the C in CAP

These two letters are often confused. The C in ACID is about rules within one database: constraints and invariants hold after each transaction. The C in the CAP theorem, about distributed systems, means linearizability: every read sees the most recent write, as if there were a single copy of the data. A single database can be ACID-consistent and still serve stale reads from an asynchronous replica, which violates CAP's consistency. Keeping the two apart avoids a lot of muddled design discussions.

7Follow-up questions

Which of the four does the database alone not guarantee?

Consistency. The database guarantees atomicity, isolation at the chosen level and durability by itself, but consistency only covers the rules we declare as constraints. Invariants that cannot be expressed as constraints, such as a transfer moving the same amount out and in, depend on the application writing correct transactions.

What does durability mean when there is a replica?

On a single server, durable means flushed to that server's disk. With asynchronous replication, a commit acknowledged by the primary may not have reached the replica yet, so a failover to that replica can lose it. Synchronous replication, such as synchronous_commit = on with synchronous_standby_names in PostgreSQL, waits until a standby has the commit record too, which extends durability to the loss of one server at the cost of commit latency.

Is a single UPDATE statement atomic without BEGIN?

Yes. With autocommit, each statement runs in its own transaction, so a single UPDATE either changes all the rows it matches or none. Atomicity across several statements, like our debit and credit, needs an explicit transaction.

8Conclusion

In this answer, we saw ACID through a money transfer. Atomicity makes the debit and credit happen together or not at all, using undo logs or MVCC versions with rollback. Consistency keeps declared constraints such as a non-negative balance, while the application keeps its own invariants. Isolation stops concurrent transfers from interfering, to the degree the isolation level allows, and durability keeps committed transfers through crashes by flushing the log before COMMIT returns. We also saw that ACID's consistency is not CAP's linearizability.

What to say in the interviewAbout 80 seconds aloud

Open with

Take a transfer of 100 from A to B, two updates in one transaction. Atomicity means both updates happen or neither does: if the server crashes after the debit, the transaction is rolled back and no money disappears.

Then, if they want more

InnoDB does that with undo logs; PostgreSQL with MVCC, where uncommitted row versions are simply never visible. Consistency means the transaction moves the database from one valid state to another according to its rules, like a CHECK that balance is never negative or foreign keys to real accounts.

The database only enforces rules we declare, so invariants such as the total staying the same are the application's job. Isolation means concurrent transfers do not see each other's partial work; without it two transfers can both read 500 and both write 400, a lost update. The isolation level, read committed, repeatable read or serializable, decides which anomalies remain possible.

Durability means once COMMIT returns, the transfer survives a crash, because the log record was flushed to disk with fsync before the commit was acknowledged, and recovery replays the log. With replicas, true durability across a node loss needs synchronous replication.

And I would note that the C in ACID is about constraints, while the C in CAP means linearizability, which is a different property.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain each letter of ACID for a relational database and give, for each one, a concrete...": https://scrivio-interview-library.netlify.app/databases/acid-and-isolation/6f2e440448/