4 types of Isolation

Okay! Imagine you and your friend are playing with LEGO blocks. You both are building your own houses at the same time.

What is Isolation?

It makes sure that when you are building your house, your friend can’t take your blocks while you’re still placing them. And you can’t take theirs either!

Without isolation, your friend might grab a block from your house before you finish, and your house might look weird or broken. But with isolation, you both finish your houses properly without messing each other up.

That’s why databases use isolation—so one person’s work doesn’t mess up another person’s work while it's still happening! 😊


I = Isolation (in ACID)

Example Scenario

Imagine a banking system where:

  1. You transfer $100 from Account A to Account B.
  2. At the same time, another transaction tries to read Account A’s balance.

Without Isolation, the second transaction might see a half-updated state (money deducted from A but not yet added to B), leading to incorrect behavior.

Isolation Levels in Databases

Most databases allow you to choose different levels of isolation, balancing consistency and performance:

  1. Read Uncommitted – Transactions can read uncommitted changes from other transactions (dirty reads possible).
  2. Read Committed – Transactions only see committed changes (no dirty reads).
  3. Repeatable Read – Ensures a transaction sees the same data if read multiple times.
  4. Serializable – The highest level; transactions are fully isolated as if they were executed sequentially.

Analogy

Think of isolation like cooking in a shared kitchen:

A transaction isolation level is defined by the following phenomena:

https://www.youtube.com/watch?v=-gxyut1VLcs

Pasted image 20250216164407.png