Skip to main content

Module 3: Databases

ACID vs BASE

Transactional ACID guarantees versus BASE eventual consistency — isolation levels, when each model fits, and how this relates to CAP.

ACID describes strong transactional databases. BASE describes availability-first distributed stores that reconcile later. Interviews use both as a vocabulary for risk — money and inventory vs likes and feeds.

What you will learn

  • Expand ACID and BASE correctly in interview language
  • Explain isolation as a spectrum, not a single switch
  • Describe eventual consistency to a non-expert
  • Choose models by domain risk (payments vs social counters)
  • Relate ACID/BASE talk to CAP without mixing definitions
Left panel lists ACID uses such as payments. Right panel lists BASE uses such as like counts.
Pick the guarantee per feature. A ledger is ACID. A like count can be BASE.

What this comparison is for

  • ACID vs BASE is a communication tool for trade-offs, not a law of physics. Use it to say which risks you accept.
  • ACID — prioritize correctness of multi-step updates
  • BASE — prioritize availability and partition resilience; reconcile later
  • Real products often mix both: checkout ACID, activity feed BASE
  • Do not equate SQL with ACID-only or NoSQL with BASE-only

ACID — the four letters

  • Say each letter with a concrete meaning. Interviewers dock vague slogans.
  • Atomicity — all-or-nothing; partial updates roll back on failure
  • Consistency — integrity rules/invariants hold after commit (DB constraints + app rules you rely on)
  • Isolation — concurrent transactions do not see illegal intermediate states
  • Durability — once committed, data survives crashes (fsync/WAL/replication policy)

Isolation is a spectrum

  • Engines rarely give perfect isolation for free. Stronger isolation usually means more locking or abort/retry.
  • Read uncommitted / read committed / repeatable read / serializable — vendor names vary
  • Weaker isolation can allow anomalies: dirty reads, non-repeatable reads, phantoms, write skew
  • Serializable / strict serializability is the gold standard and the most expensive
  • Pick the weakest level that still protects your invariant
  • In interviews, name the anomaly you fear (e.g. double spend) more than the level brand

When ACID fits

  • Choose ACID when a wrong intermediate or lost update is unacceptable.
  • Payments, ledgers, transfers, wallet debits
  • Inventory reservation and seat booking
  • Unique constraints that must never double-issue (coupon codes, usernames)
  • Multi-row updates that must succeed together (order + order_items)
  • Cost: lower write availability under partitions; more contention under load

BASE — the three ideas

  • BASE is informal shorthand from distributed-systems culture. Define it cleanly.
  • Basically Available — the system keeps responding under partial failure
  • Soft state — values may change as replicas catch up, even without new client writes
  • Eventual consistency — if writes stop, replicas converge to the same values
  • Often paired with conflict resolution: LWW, version vectors, CRDTs, merge logic
  • Availability and latency wins; temporary disagreement is the price

Eventual consistency in plain words

  • Explain it so a PM would understand — that is what interviewers want.
  • Two users may briefly see different like counts or profile fields
  • The system has a repair path (anti-entropy, read repair, sync) to converge
  • Eventual is not forever wrong — it is temporarily divergent with a plan
  • You must still define conflict rules when two writes disagree
  • Session guarantees (read-your-writes) are often layered on top

When BASE fits

  • Choose BASE-style stores when stale or briefly conflicting data is cheaper than downtime.
  • Social counters, view counts, “last seen” presence
  • Activity feeds and recommendation signals
  • Multi-region high-availability shopping metadata (with care)
  • Analytics pipelines and derived aggregates
  • Still design for abuse cases: money-adjacent flows should not casually go BASE

ACID vs BASE — quick comparison

  • Use this side-by-side when asked which model you prefer.
  • Goal — ACID: correct transactions; BASE: keep serving and converge later
  • Failure mode — ACID: abort/error; BASE: stale or conflicting reads
  • Ops focus — ACID: locking, deadlocks, failover RPO; BASE: conflict repair, lag
  • Scale story — ACID primary often scales reads via replicas; writes still hard
  • Interview move — assign per feature, not per company

Mixing models in one product

  • Senior answers slice the system: different features get different guarantees.
  • Checkout and billing on an ACID store
  • Feed fan-out / counters on an eventually consistent path or cache
  • Outbox/inbox patterns to publish events after ACID commits
  • Idempotency keys so retries do not double-charge even with queues
  • Do not force one database ideology onto every table

Common misconceptions

  • These slogans lose easy points.
  • “NoSQL means no ACID” — many offer transactions or tunable consistency
  • “BASE means no consistency” — it means delayed/weaker consistency with convergence
  • “ACID C equals CAP C” — different definitions; keep them separate
  • “Eventual consistency is fine for money” — usually not without a stronger ledger elsewhere
  • Treating BASE as a formal theorem dual of ACID

Interview framing

  • Use this order when data correctness comes up.
  • Name the invariant (no negative balance, unique seat, approximate counter OK)
  • Pick ACID or BASE for that feature and state the user-visible failure
  • If ACID: mention atomic multi-row update + isolation concern
  • If BASE: mention convergence + conflict rule
  • Show a second feature that chooses the other side

Quick revision checklist

  • Expand every letter — do not only recite the acronym.
  • Assign ACID/BASE per feature, not per database brand.
  • Don’t paint NoSQL as “no consistency.”
  • Separate ACID Consistency from CAP Consistency.
  • For BASE, describe the user-visible stale window.
  • Mention isolation anomalies when double-updates matter.

FAQs

Is BASE the opposite of ACID?

It is a different design emphasis, not a formal dual. Use it as a communication tool for trade-offs, not as a mathematical negation.

Does SQL always mean ACID?

Relational engines are built for transactions, but isolation level, deployment, and cross-shard setups change what you actually get. Read the guarantees you rely on.

Can a NoSQL store be ACID?

Some provide multi-document transactions or strong consistency modes. Talk about the configured guarantees, not the marketing category.

Is eventual consistency the same as “no consistency”?

No. It means replicas may diverge briefly and then converge. You still need conflict rules and often session-level guarantees.

How does this relate to CAP?

CAP is about partition behavior (CP vs AP). ACID/BASE is about transactional vs availability-first design style. Overlap exists in spirit, but keep the vocabularies distinct.

What should I choose for inventory in a flash sale?

Prefer ACID (or strong transactional reservation) so two users cannot buy the last item. Approximate counters elsewhere can still be BASE.

Practice

Learner’s Task

  • Practice out loud for 8–10 minutes. Slice one product into ACID and BASE features.
  1. Pick a product (food delivery or e-commerce) and list two features that need ACID and two that can be BASE.
  2. Expand ACID and BASE fully; for each chosen feature, state the user-visible failure mode.
  3. For one ACID feature, name the invariant and an isolation risk (e.g. double booking).
  4. For one BASE feature, describe the stale window and how replicas eventually converge.
  5. Write a 4-sentence closing: feature split, why ACID where money/stock matters, why BASE elsewhere, and one misconception you avoided.