Skip to main content
Definition Website Computer and Technology

Database Transaction

Subject: Computer and Technology noun /ˈdeɪ.təˌbeɪs trænˈzæk.ʃən/ 1 definition

  1. Definition (noun)

    Entry #228 · Updated

    A Database Transaction is a single logical unit of work performed against a database that groups one or more read and write operations into an indivisible execution boundary. Its core purpose is to ensure that either all operations succeed and commit permanently, or all partial changes are rolled back on failure so the database never persists a half-completed state. Typically governed by ACID properties—atomicity, consistency, isolation, and durability—transactions preserve data integrity across concurrent workloads and unexpected system failures.

    Common Types

    • Flat Transactions: Standard single-level transactions starting with BEGIN and ending with COMMIT or ROLLBACK, where all included statements succeed or fail as one undivided scope.

    • Nested Transactions: Hierarchical transactions containing child subtransactions or savepoints that can roll back independently on localized errors while deferring final durability until the root parent commits.

    • Distributed Transactions: Multi-node transactions coordinating updates across independent databases or shards, typically relying on protocols like two-phase commit (2PC) to ensure every participant commits or aborts together.

    • Read-Only Transactions: Query-only transactions that perform no data mutations, enabling engines using multi-version concurrency control (MVCC) to skip write locks and read from a consistent point-in-time snapshot.

    Example

    When moving $500 from checking account 1042 to savings account 2089, a payment service wraps the UPDATE debit and credit queries inside a BEGIN and COMMIT block. If the database server crashes after deducting $500 from account 1042 but before crediting account 2089, recovery rolls back the incomplete debit so the funds never disappear.