Skip to content
Ameen Abozaid
MID-041

NoSQL fundamentals

  • 6 Lessons
  • 1.5 h practice (estimate)
On this page 8 topics

Overview

Topics

  • Key-value
  • document
  • column-family
  • graph databases

Learn first

1.5 h of practice (estimate)

Learning outcomes

  1. Describe key-value, document, wide-column, and graph models with a fitting use case for each.
  2. Explain query-driven data modeling and its trade-off against flexible querying.
  3. Relate each store's consistency and scaling model to the CAP/PACELC discussion.

Lessons

  1. 01Why NoSQL exists
  2. 02Key-value and document stores
  3. 03Wide-column stores
  4. 04Graph databases
  5. 05Modeling for queries
  6. 06Demo: the same data in four models

Lab and exercises

Lab

MID-041-LAB1 · Model comparison

Outcomes: 1–3 · Time: ~1.5 h Model Shop's reviews (rating, text, product, customer, date) in a document, a wide-column, and a relational form. For each model list the queries it supports well, those it supports badly, and its consistency and scaling behavior. Acceptance: comparison table covering at least five queries across the three models.

Exercises (assessment: quiz)

IDOutcomeTask
MID-041-EX011Match each use case to a model: session lookup, product with varying attributes, time-series sensor writes, "friends of friends".
MID-041-EX021Give one Shop feature fitting each of key-value, document, wide-column, and graph.
MID-041-EX032List three queries for order history, then design a wide-column table for each.
MID-041-EX042Explain what you give up when you model for queries only.
MID-041-EX053State, for a Cassandra-like store and a single-node PostgreSQL, the side each takes in CAP and what PACELC adds.
Show solutions
  • EX01 Session: key-value. Varying attributes: document. Time series: wide-column. Friends of friends: graph.
  • EX02 Key-value: sessions/cart cache. Document: reviews/product attributes. Wide-column: activity/event log. Graph: "also bought" recommendations.
  • EX03 E.g. orders_by_customer(customer_id, placed_at, order_id), orders_by_status(status, placed_at, order_id) (watch partition size), order_by_id(order_id). Each table answers one query.
  • EX04 Ad hoc and new queries need new tables or a redesign; data is duplicated, so updates touch several places.
  • EX05 Cassandra-like: tunable, commonly leans to availability (AP) in a partition and low latency otherwise. Single-node PostgreSQL: no partition within one node; consistency is strong. PACELC: in the normal case, trade latency against consistency. Verify settings per product.

Outcomes 1-3 are also checked by the quiz and the lab table.

Quiz

Outcomes: O1 the four models · O2 query-driven modeling · O3 consistency and scaling.

A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.

  1. 1Best fit for "customers who bought X also bought":O1
  2. 2A document store is best when:O1
  3. 3A key-value store lookup is by:O1
  4. 4Wide-column stores are designed around:O1
  5. 5Query-driven modeling means:O2
  6. 6A trade-off of query-driven modeling:O2
  7. 7"Schemaless" really means:O2
  8. 8CAP says during a network partition you choose between:O3
  9. 9PACELC adds that, without a partition, you still trade:O3
  10. 10Why do many wide-column stores scale writes well?O3

Practical part

Lab MID-041-LAB1 (comparison table of reviews in three models). Pass: quiz at least 8/10 and a lab table with at least five queries.

Common mistakes

"schemaless" meaning "no schema design".

Assessment

Quiz.

Career relevance

Data selection (MID-044) and database architecture (ARC-016).

Type to search levels, phases, modules and lessons.