Database Transactions
In depthConcept
Also known as: Transacties
A group of database operations that succeed or fail as one: all or nothing.
Database Transactions, explained
Written by EduVerseWhat it is
A transaction groups several database operations so they count as one unit of work. Either all of them are saved together with a COMMIT, or, if something goes wrong halfway, a ROLLBACK undoes everything. Databases add guarantees around this, often summed up as ACID.
Why teams use it
Many changes only make sense together: take money from one account and add it to another, or create an order and reserve its stock. If the server crashes between those steps without a transaction, your data ends up half-changed and inconsistent, and cleaning that up by hand is painful.
An example from work
Your checkout code inserts an order and then its order lines. During testing the second insert fails on a validation error, and you notice an empty order left behind in the table. Wrapping both steps in a transaction, for example with prisma.$transaction, means a failure leaves no trace.
Our own explanation, not a quote from the book.
In the book
Sentences from The Software Realm, Decoded that mention Database Transactions, exactly as printed.
1 more passages about Database Transactions in the full book
Read every conversation where Database Transactions comes up, with the interactive slides and demos.
Where it fits
Data integrity for related changes
Coverage in the book
Covered in depth: multiple pages with explanations, examples and simulations.