What a Transaction Is
A transaction groups several reads and writes into a single unit that either fully commits or fully rolls back. This is how a database moves money between accounts without ever losing or duplicating it.
The ACID Properties
- Atomicity means all steps apply or none do.
- Consistency means the database moves from one valid state to another, honoring constraints.
- Isolation means concurrent transactions do not corrupt each other.
- Durability means once committed, data survives a crash.
How It Works
The engine writes intended changes, and on commit it makes them permanent and visible. On rollback or failure it discards them. A crash mid transaction leaves no partial effects because recovery replays or undoes from the log.
Keep transactions short. Long ones hold locks and resources, hurting concurrency.
Key idea
A transaction makes a group of operations atomic, consistent, isolated, and durable, so they all take effect or none do.