Skip to the page
Tecyfy

SQL interview question · hard

What are transactions, and what are the ACID properties? Why are they important?

The short answerA transaction is a group of database operations that succeed or fail as one unit.

The full answer

A transaction is a group of database operations that succeed or fail as one unit. The ACID properties (atomicity, consistency, isolation and durability) are the guarantees that make that true even with many users and in the middle of crashes.

BEGIN;
UPDATE accounts SET balance = balance - 500 WHERE account_id = 1;
UPDATE accounts SET balance = balance + 500 WHERE account_id = 2;
COMMIT;   -- or ROLLBACK; to undo both
PropertyMeaningWithout it
AtomicityAll statements in the transaction take effect, or none doMoney leaves one account and never arrives in the other
ConsistencyEach transaction moves the database from one valid state to another; constraints hold at commitOrders pointing to customers that don't exist
IsolationConcurrent transactions don't see each other's unfinished work, to the degree the isolation level promisesReports reading half-finished updates; lost updates
DurabilityOnce committed, changes survive crashes and power lossA confirmed payment disappears after a restart

How databases provide them

  • Atomicity and durability: a write-ahead log records changes before they are applied, so after a crash the database can redo committed work and undo the rest.
  • Isolation: locks, multi-version concurrency control (readers see a snapshot), or both.

Isolation levels are a trade-off

  • Read committed: each statement sees data committed before it began. The default in PostgreSQL, SQL Server and Oracle.
  • Repeatable read: the transaction keeps seeing the same data it read. The default in MySQL's InnoDB.
  • Serializable: the result is as if transactions ran one after another; the database may abort a transaction that would break that, so the application must retry. Higher levels prevent more anomalies but cause more waiting or retries. Pick the lowest level that rules out the anomalies your logic can't tolerate, and test what happens when two users act at the same moment.

Why it matters Payments, inventory, bookings and anything else where partial or interleaved updates would cause real harm rely on transactions. Many distributed and NoSQL systems relax some of these guarantees for scale, often offering eventual consistency across replicas, which pushes the work of handling conflicts onto the application.

Last updated 16 October 2026

Sources

Where each fact comes from

  1. 1Transactions
  2. 2Transaction isolation