Back to Backend

What is a database transaction and what does ACID mean?

A transaction is a unit of work sent to the database as one logical step. ACID is the classic checklist: Atomicity (all statements succeed or none apply), Consistency (constraints still hold after commit), Isolation (concurrent transactions do not read each other’s half-finished work in bad ways - level matters), Durability (after commit, data survives normal crashes). In interviews, connect this to payment flows: you do not want a debit without a matching credit. ORMs often expose transaction boundaries; you still need to think about isolation when two users buy the last item.

BEGIN;
UPDATE accounts SET balance = balance - 10 WHERE id = 1;
UPDATE accounts SET balance = balance + 10 WHERE id = 2;
COMMIT;
-- ROLLBACK; on failure

Start simple: try this concept in a tiny project before moving to advanced tools.

sqltransactionspostgres

Want to check this topic right now?

Check this question