Skip to content
>devspeak
← glossary
level 4Databases

Transaction

also: transactions, transactional, database transaction

A group of database changes that succeed together or fail together, so you never end up with only half of them saved.

a bit more technical

A unit of work in which several queries are applied atomically: either all are committed or all are rolled back. Transactions also keep in-progress changes hidden from other users until they finish. These guarantees are summarized as ACID.

picture it

Transferring money between two bank accounts. Taking it from one and adding it to the other must both happen, or neither. Money vanishing halfway isn't an option.

why it matters

When one action changes several things, like placing an order and reducing stock, a crash halfway can leave data inconsistent. Asking "is this in a transaction?" prevents a whole family of bugs.

what your agent might say
agent
I'll wrap the order insert and the inventory update in a single transaction, so if either fails, both are rolled back.
how you might use it
you → your agent
Save the booking and its payment record in one transaction, so we never end up with one without the other.
common mistake

Thinking "transaction" only means a payment. In database talk, it's any group of changes that must succeed or fail as one.

builds on