Skip to content

Transaction

Prime #
163
Origin domain
Computer Science & Software Engineering
Also from
Economics & Finance, Operations Research
Aliases
Atomic Operation, Acid Transaction, Logical Unit of Work, Acid, Acid Properties
Related primes
Idempotence, Concurrency, consistency, saga pattern

Core Idea

  • A transaction is a sequence of operations treated as a single logical unit, ensuring consistency by either fully completing ("commit") or fully rolling back in the event of failure.

How would you explain it like I'm…

All-Or-Nothing Swap

Pretend you trade two stickers for a friend's toy car. Either you both swap and it's done, or nothing happens and you keep what you had. There's no halfway where you give the stickers but don't get the car. That all-or-nothing swap is a transaction.

All-Or-Nothing Step

A transaction is a group of steps that have to all happen together or not happen at all. When you move money from your savings to your checking, the bank has to subtract from one and add to the other. If it only did the subtracting and then crashed, your money would vanish. So the bank treats both steps as one indivisible action: both succeed, or both are undone. No half-finished state is ever allowed to be seen.

Transaction

A transaction is a sequence of operations treated as a single, all-or-nothing logical unit. Either every step takes effect together (commit) or none of them do (rollback), so no observer ever sees a partial or inconsistent state. In databases this is captured by the ACID properties: Atomicity (all or nothing), Consistency (the system always satisfies its rules), Isolation (concurrent transactions don't interfere visibly), and Durability (once committed, the change survives crashes). The idea extends well beyond databases — any system that does multi-step state changes under failure and concurrency needs a way to look indivisible to outsiders.

 

A transaction is a sequence of operations treated as a single, indivisible logical unit of work: either all its effects become visible to other observers (commit) or none of them do (abort/rollback), with no partial or corrupted intermediate state ever visible to concurrent or subsequent observers. In classical database settings the construct is characterized by the ACID properties — Atomicity (all-or-nothing execution), Consistency (preservation of integrity constraints), Isolation (concurrent transactions appear serially executed), and Durability (committed effects survive system failure). The essential commitment is that any system performing multi-step state changes must guarantee that failures, concurrency, and arbitrary interleavings cannot leave observable intermediate or inconsistent states; atomic commit/rollback is the primary mechanism for that guarantee; and the cost of providing the guarantee scales with the strength of isolation and durability required. The pattern generalizes well beyond relational databases — distributed protocols, filesystems, financial settlement, version control merges, and serverless workflows all instantiate transactional structure.

Broad Use

  • Databases: Traditional ACID transactions guarantee data integrity.

  • Finance: Bank transfers that must succeed or fail in entirety (no partial debits).

  • Supply Chain: Multi-step inventory updates where all steps must align (ship goods, update stock, invoice).

  • Social Contracts: Deals or agreements that become void if certain conditions are not met (all-or-nothing).

Clarity

Simplifies multi-step processes by ensuring atomicity, preventing partial or corrupted outcomes.

Manages Complexity

Simplifies multi-step processes by ensuring atomic completion.

Abstract Reasoning

Encourages design where partial failures don't leave systems in a corrupted state.

Knowledge Transfer

Transaction concepts appear anywhere sequences of dependent actions must either happen in full or not at all.

Example

Online shopping cart checkout: Payment, shipping details, and inventory reduction occur as one transaction. If any step fails (e.g., payment declined), the entire process is reversed to avoid inconsistencies.

Relationships to Other Primes

One-hop neighborhood: parents above, mutual partners to the right, children below.Transactioncomposition: Reversibility and IrreversibilityReversibility a…composition: ExchangeExchange

Parents (2) — more general patterns this builds on

  • Transaction presupposes Exchange — Transaction presupposes exchange because the indivisible all-or-nothing commit-or-rollback unit operates on multi-party transfers requiring mutual commitment.
  • Transaction presupposes Reversibility and Irreversibility — Transaction presupposes Reversibility and Irreversibility: atomicity and rollback require the option to undo a partial commit before observers see it.

Path to root: TransactionReversibility and Irreversibility

Not to Be Confused With

  • Transaction is not Concurrency because Transaction is a logical unit of work with all-or-nothing atomicity properties (commit or abort as an indivisible whole), while Concurrency is the simultaneous execution of multiple independent computational threads or processes that may or may not interact; transactions manage the consistency of sequential operations, concurrency manages the interleaving of parallel operations.
  • Transaction is not Transaction Costs because Transaction is the computational/logical operation itself (a sequence of steps treated as indivisible), while Transaction Costs are the economic frictions and expenses (in time, money, effort) incurred in negotiating, monitoring, and enforcing any exchange; one is the operational unit, the other is the costs of carrying out such units in economic contexts.
  • Transaction is not Pipeline because Transaction is a single indivisible logical unit with all-or-nothing semantics and ACID properties, while Pipeline is a sequence of stages where each stage operates on input from the previous stage and produces output for the next, allowing multiple items to flow through stages in parallel; transactions enforce consistency across a single unit, pipelines optimize throughput across multiple units.