DATABASE
    intermediate

    NoSQL Database Models

    Software Engineer path · lesson 60 of 99
    The idea
    A document store keeps the whole order as one self-contained folder. A key-value store is a coat-check ticket — hand over the number, get the blob back, no peeking inside. A wide-column store is a spreadsheet where each customer gets their own sparse row of time-stamped columns.
    How to use
    Switch tabs to see the exact same order reshaped by each model, then check which access pattern each one is actually built for.
    One document, nested fields
    {
      "orderId": "ord_8842",
      "customer": {
        "name": "Priya Shah",
        "email": "priya@example.com"
      },
      "items": [
        {
          "sku": "LP-2200",
          "qty": 1,
          "price": 1299
        },
        {
          "sku": "BK-0087",
          "qty": 2,
          "price": 24
        }
      ],
      "shippingAddress": {
        "city": "Austin",
        "state": "TX",
        "zip": "78701"
      },
      "status": "shipped",
      "createdAt": "2024-03-01T14:22:00Z"
    }
    1 fetch
    reads
    flexible
    schema
    arbitrary
    nesting

    Key insight

    The whole order — items array, nested address, everything — lives in one document. No joins to reconstruct it, and the next order can have extra fields (a coupon code, a gift note) without altering every other document's shape.

    Which NoSQL family?

    Sort

    Sort each description into the data model it fits.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    Document

    Drop items here

    Key-value

    Drop items here

    Wide-column

    Drop items here
    6 pieces left to place

    Test your knowledge

    20 questions
    Question 1 of 20
    Score: 0

    A document database stores a record as…

    The short version

    A document store keeps the whole order as one self-contained folder. A key-value store is a coat-check ticket — hand over the number, get the blob back, no peeking inside. A wide-column store is a spreadsheet where each customer gets their own sparse row of time-stamped columns.

    In more depth

    NoSQL Database Models

    NoSQL isn't one thing — it's a family of models, each optimized for a specific access pattern by relaxing something a relational database guarantees by default.

    Document stores (MongoDB) keep whole, possibly nested, possibly schema-varying records together — good when you read/write an entity as a unit.

    Key-value stores (DynamoDB, Redis) are pure O(1) lookup by key with no query language — the fastest, simplest model, ideal for caching and session data.

    Wide-column stores (Cassandra) partition rows by a key and cluster them by a sort key (often time), making "give me this partition's recent rows" extremely fast — the backbone of time-series and event-log workloads.

    Each trades cross-entity consistency or joinability for that speed, landing differently on the CAP triangle by default.

    Interview Questions

    MongoDB
    Amazon
    Datastax
    Amazon

    Love this visualization?

    Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.

    100% free • No credit card required