4.4.24 · D3Databases

Worked examples — NoSQL — document (MongoDB), key-value (Redis), column (Cassandra), graph (Neo4j)

2,119 words10 min readBack to topic

This deep dive lives under the NoSQL parent note. If any term here feels new, the parent built it first.


The scenario matrix

Before working examples, let us enumerate every case class this topic can produce. Think of it like listing all quadrants before doing trigonometry — we want zero surprises.

Cell Case class What makes it tricky Worked in
A Access-pattern → pick a family matching the query shape to the model Ex 1, Ex 2
B Quorum, strong-read region () the "safe" sign of the inequality Ex 3
C Quorum, eventual region () the "unsafe" sign — reads may miss writes Ex 4
D Quorum degenerate: or one side does all replicas Ex 5
E Quorum degenerate: the minimum-cost extreme Ex 4
F CAP limiting case: partition PRESENT forced CP-vs-AP choice Ex 6
G CAP limiting case: partition ABSENT you can have both C and A Ex 6
H Real-world word problem (multi-system) combine several families in one app Ex 7
I Exam twist / trap the "obvious" answer is wrong Ex 8

We treat the quorum inequality like a number line: the sign of is the whole story. Positive → strong, zero-or-negative → eventual. Every quorum example below is chosen to hit a different sign or a boundary of that line.

Figure — NoSQL — document (MongoDB), key-value (Redis), column (Cassandra), graph (Neo4j)

Cell A — Access pattern picks the family


Cells B, C, D, E — every quorum sign

Recall the parent's rule: with replicas, write-acks , read-nodes , The reason is pigeonhole: the read nodes and write nodes overlap in at least nodes. We now walk the sign of across all its cases.

Figure — NoSQL — document (MongoDB), key-value (Redis), column (Cassandra), graph (Neo4j)

Cells F, G — the CAP limiting cases

Figure — NoSQL — document (MongoDB), key-value (Redis), column (Cassandra), graph (Neo4j)

Cell H — the real-world word problem


Cell I — the exam trap


Recall Sign-of-quorum cheat sheet

means what for reads? ::: A read is guaranteed to see the latest write (strong) — overlap . means what? ::: Reads may miss a fresh write (eventual); overlap can be . For , is strong or eventual? ::: Eventual (). During a partition, the real choice is between? ::: CP (refuse to stay consistent) vs AP (answer stale to stay available). Why can't always be used? ::: A single down replica blocks every write — no write-availability.