Transaction
A transaction is a group of operations executed as a single logical unit satisfying ACID properties — all or nothing.
Purpose
To bundle multiple operations into an atomic unit, guaranteeing correctness under failures and concurrency.
Mechanism
BEGIN starts it, operations execute, COMMIT commits or ROLLBACK aborts. Atomicity is guaranteed by the undo log, durability by the redo log/WAL, isolation by locks or MVCC. Distributed transactions use 2PC/3PC or the Saga pattern.
Use cases
- Bank transfers
- Orders and inventory deduction
- Multi-table relational updates
- Distributed cross-service operations
Examples
- Input
BEGIN; A→B 100; COMMITOutputAtomic transferAll or nothing
Common errors
- No explicit transaction causes partial commits
- Wrap related operations in a transaction
Related terms
ACID
ACID is the four properties of relational transactions: atomicity (all or nothing), consistency (constraints preserved), isolation (concurrency without interference), and durability (committed data is never lost). GLOSSARY
Isolation Level
Isolation levels define visibility between concurrent transactions, from read uncommitted to serializable; higher levels give stronger consistency but lower concurrency. GLOSSARY
Primary Key
A primary key is the column or column combination that uniquely identifies each row in a table — non-null and unique; the row identity. GLOSSARY