ACID Cheat Sheet

ACID are 4 properties of database transactions. A database transaction may contain multiple read / write operations.

ACID makes sense when there are multiple transactions happening at the same time.

  • Atomicity = Is a transaction everything-or-nothing?
  • Consistency = How up-to-date is the data?
  • Isolation = How independent are the operations?
  • Durability

Isolation

Read Phenomena

  • Dirty reads = non-committed data will be read
  • Non-repeatable reads = two selects in one transaction return different data as another transaction committed an update
  • Phantom reads = two range selects in one transaction return different rows as another transaction added new rows

Isolation Levels

  • (Highest level) Serializable = read-lock + write-lock + range-lock
  • Repeatable reads = read-lock + write-lock, phantom reads may happen
  • Read committed = write-lock, non-repeatable reads may happen
  • Read uncommitted = no locks, dirty reads may happen