Skip to content
uencoder

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; COMMIT
    Output
    Atomic transfer

    All or nothing

Common errors

No explicit transaction causes partial commits
Wrap related operations in a transaction

Related terms

References