Module 1 - Data Storage

ACID vs BASE Properties

Two opposing philosophies for database consistency and availability trade-offs.

1The Bank vs Social Media Analogy

Simple Analogy
ACID (Bank Transfer): When you transfer $100, either it fully completes or fully fails. No partial states. You need absolute certainty your money is safe.

BASE (Social Media Likes): If a like count shows 999 instead of 1000 for a few seconds, nobody cares. Eventually it'll be correct. Speed and availability matter more.

2ACID Properties

ACID is a set of properties that guarantee database transactions are processed reliably, even in the face of errors, power failures, etc.

A

Atomicity

All or nothing. Transaction either fully completes or fully rolls back. No partial updates.

Example: Transfer fails mid-way? Both accounts return to original state.

C

Consistency

Database moves from one valid state to another. All rules/constraints are enforced.

Example: Account balance can't go negative if that's a constraint.

I

Isolation

Concurrent transactions don't interfere. Each sees a consistent view.

Example: Two transfers happening simultaneously won't corrupt data.

D

Durability

Once committed, data survives crashes. Written to persistent storage.

Example: Power failure after commit? Data is still there on restart.

3BASE Properties

BASE is an alternative model that prioritizes availability and partition tolerance over strong consistency.

BA

Basically Available

System guarantees availability. Responses may be stale or partial, but always responds.

Example: Shopping cart always loads, even if inventory count is slightly off.

S

Soft State

State may change over time without input due to eventual consistency.

Example: Replicas may show different values temporarily.

E

Eventually Consistent

Given enough time without updates, all replicas will converge to same value.

Example: After a few seconds, all nodes show the same like count.

4Comparison

AspectACIDBASE
ConsistencyStrongEventual
AvailabilityMay block for consistencyAlways available
ScalabilityHarder to scaleHorizontally scalable
Use CaseFinance, inventorySocial, caching, analytics
DatabasesPostgreSQL, MySQLCassandra, DynamoDB, MongoDB

5When to Use Which

Choose ACID

  • ✓ Financial transactions
  • ✓ Inventory management
  • ✓ Booking systems
  • ✓ Any "correctness is critical" scenario

Choose BASE

  • ✓ Social media feeds
  • ✓ Analytics/metrics
  • ✓ Shopping carts (before checkout)
  • ✓ Any "availability is critical" scenario

6Key Takeaways

1ACID guarantees correctness: atomic, consistent, isolated, durable
2BASE prioritizes availability: basically available, soft state, eventually consistent
3ACID is harder to scale but safer for critical data
4BASE enables horizontal scaling at the cost of temporary inconsistency
5Many systems use both: ACID for orders, BASE for recommendations

?Quiz

1. A bank account balance must never be negative. Which ACID property ensures this?

2. Social media like counts being slightly off for a few seconds is acceptable because of: