Web Dev Academy Databases · NoSQL databases Tool 47 / 64
Databases

NoSQL databases

Data without rigid tables. NoSQL stores flexible documents, key/value pairs, graphs and more — trading SQL's strict schema for speed, scale and shape-shifting freedom.

Demo 01

Document store — MongoDB styleSimulation

In a document database, each record is a free-form JSON-like document. No CREATE TABLE, no fixed columns — two documents in the same collection can have different fields. Add some below; notice how each can have a different shape.

db.users.find( )
// Real MongoDB shell — same idea, on a real server
db.users.insertOne({ name: "Ada", role: "engineer", age: 36 })
db.users.insertOne({ name: "Grace", city: "NYC" })  // different shape, no problem
db.users.find({ role: "engineer" })
Demo 02

Flexible schema is the whole point

Relational databases force every row into the same columns. Document stores let your data evolve: add a field to one record without migrating the rest. Great for fast-moving products and deeply nested data (an order with its line-items embedded inside it).

{
  "_id": "a1f9",
  "name": "Ada",
  "orders": [                       // nested array — no JOIN needed
    { "product": "Monitor", "amount": 229 },
    { "product": "Keyboard", "amount": 49.99 }
  ]
}
Demo 03

Redis: memory-speed key/valueSimulation

Redis keeps data in RAM, so a GET returns in microseconds — perfect for caches, sessions and leaderboards. Set a few keys, then fetch one and watch how a memory read compares to going to disk.

GET
Set a key, then GET it to race memory vs disk.
🧠 Redis (in-memory)
💽 Disk-based lookup
# Real Redis CLI — runs on a real server
SET session:42 "user=ada"
GET session:42        # → "user=ada", in ~0.2 ms from RAM
EXPIRE session:42 3600  # auto-delete after an hour
Demo 04

When NoSQL shines (and when SQL wins)

There's no single winner — pick the model that fits your data. NoSQL trades guarantees for flexibility and horizontal scale.

Reach for NoSQL when…

  • • Your data shape changes often
  • • You need massive horizontal scale
  • • You store nested / hierarchical objects
  • • You need millisecond caching (Redis)

Stick with SQL when…

  • • You need strong relationships & JOINs
  • • Transactions must be all-or-nothing
  • • The schema is well-defined & stable
  • • You run complex aggregate reports
Demo 05

The NoSQL family

"NoSQL" is an umbrella over several very different models.

Document — MongoDB, CouchDB Key/Value — Redis, DynamoDB Wide-column — Cassandra, HBase Graph — Neo4j, Neptune Search — Elasticsearch
i
The document store and the Redis speed race are an interactive JavaScript simulation — real MongoDB and Redis run as server processes, not inside a browser tab, so the in-page collection lives in a JS array and the timing bars are illustrative (the ~0.2 ms memory read vs a slower disk read is realistic in spirit, not measured on your machine). The real MongoDB shell and Redis CLI commands shown in the dark code blocks are exactly what you'd type against a live server. The shared CSS shell provides the page styling.

↑ All 64 tools