NoSQL Data Models

Context: FIT2094_MOC · the four ways NoSQL structures data · choice driven by data shape + access pattern · MongoDB is a document store Parent Framework: NoSQL Databases

Quick Revision

  • 🎯 Objective: pick a model by access pattern ➔ key-value, document, column-family (aggregation-oriented) or graph (traversal-oriented).
  • 📦 Core Components: key-value ➔ opaque blob by key | document ➔ queryable JSON | column-family ➔ wide/time-series | graph ➔ nodes+edges.
  • ⚡ Key Constraint: aggregation models fetch a whole record fast but can’t cheaply follow relationships — that’s the graph model’s job.

📝 Core

1. Key-value store

  • Structure ➔ unique key → opaque value (string/number/blob/JSON); direct key→location lookup, extremely fast.
  • Limit ➔ value is opaque: can’t query “balance = 0” without reading/parsing every value. Redis, DynamoDB, Oracle NoSQL.

2. Document store

  • Structure ➔ semi-structured JSON/BSON per record; DB understands fields ➔ can query inside a document; documents in a collection may differ. MongoDB.

3. Column-family (wide-column)

  • Structure ➔ row key → column families (a map of maps); variable columns per row; families stored together on disk.
  • Strength ➔ query many rows but few columns; time-series. Cassandra (eBay, Netflix).

4. Graph database

  • Structurenodes + edges with properties/labels/direction; built on graph theory.
  • Strengthtraversal (“friends-of-friends who like jazz”) — cheap where relational needs many JOINs. Neo4j, HyperGraphDB.

⚖️ Core Decision Matrix

ModelData shapeBest accessQuery inside value?
Key-valueopaque blob by keypoint lookup by key❌ opaque
Documentvarying JSON docswhole-record + field queries
Column-familywide rows, familiesmany rows × few columns; time-series✅ by column
Graphnodes + edgesrelationship traversal✅ via edges

When It Flips: the first three are aggregation-oriented (group one entity's data together, retrieve as a unit); the graph model is traversal-oriented (follow relationships across entities) — the opposite optimisation.

🧠 Active Recall