The Major NoSQL Shapes: Document, Key-Value, Column, Graph
Understand the idea
Why 'NoSQL' is four completely different database engines masquerading under one label.
The idea
The term is not just one database engine; it covers four different ways of storing and organizing data, each built for a specific kind of job:
- (e.g., MongoDB, Couchbase): Data is stored as flexible, nested documents (like JSON). This is ideal when data is hierarchical and read together as a complete bundle (such as user profiles, blog posts with their comments, or product listings).
- (e.g., Redis, Memcached): Data is stored like a fast dictionary where each item is accessed by a unique key. Because looking up a key is nearly instant, key-value stores are great for caching, keeping user login sessions active, and tracking live counters.
- Wide-Column Stores (e.g., Apache Cassandra, ScyllaDB): Data is stored in rows with flexible columns grouped together. Built to handle massive numbers of writes across many servers, wide-column stores power server metrics, sensor logs, and large activity feeds.
- Graph Databases (e.g., Neo4j, Amazon Neptune): Data is stored as entities (nodes) connected by explicit relationships (edges). Graph stores are built for relationship-heavy questions (like 'who are friends of friends?' or detecting fraud rings) where normal SQL would need dozens of slow .
What changes
| Model Shape | Leading Systems | Primary Access Pattern | Best Real-World Fit |
|---|---|---|---|
| Document | MongoDB, Couchbase | Key or query matching nested document fields | Content management, polymorphic catalogs, mobile payloads |
| Key-Value | Redis, Memcached | Single key lookup / set / delete (O(1)) | Session storage, cache layers, real-time counters, job queues |
| Wide-Column | Cassandra, ScyllaDB | Partition key lookup + clustering key range | High-volume time-series, messaging history, IoT sensor logs |
| Graph | Neo4j, Amazon Neptune | Pointer chasing / graph traversal along edges | Social networks, fraud detection, recommendation engines |
The command
Demonstrating the four data shapes in code
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
The mistake
Check the result
Run the example to see code representations of key-value, document, and graph structures, highlighting how each model optimizes for distinct query patterns.
Guided challenge
Match workload to NoSQL shape
Update the function to return 'graph' for fraud_ring_edges and 'key-value' for http_session_cache.
Match workload to NoSQL shape
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
EXPECTED RESULT
graph key-value
Hints 0/1
Use all hints or make 3 failed checks (0/3).
Free exploration
Change this example and run it again. Each run is a new process. Nothing is saved.
Your variation
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 150 XP. You can always revisit it.