← Lessons

quiz vs the machine

Gold1380

Databases

Transactions and ACID

Grouping operations so they all succeed or all fail together.

5 min read · core · beat Gold to climb

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.

Check yourself

Answer to earn rating on the learn ladder.

1. Atomicity guarantees that:

2. Why keep transactions short?

3. Durability ensures committed data: