A transaction groups several database writes into one atomic unit. Either all of them commit, or none of them do. That is the guarantee you are buying: you never end up with half the work done and a database that contradicts itself.
People recite the full ACID list (atomicity, consistency, isolation, durability), but the property I actually reach for day to day is atomicity. All or nothing.
A real scenario: checkout
Placing an order looks like one action to the user, but under the hood it is several writes that all have to agree with each other.
Order.transaction do






