Part 5 of 5 · 3 min read
Exercises
Easy
Easy 1: Name the family (15 minutes)
For each use case, name the best-fitting family: a social network's friend connections, a simple session cache keyed by session ID.
Done when: graph database and key-value store are correctly matched.
Hint
Friend connections are relationships, so graph; a session lookup by ID is a simple key-based lookup, so key-value.
Easy 2: What NoSQL does not mean (15 minutes)
Explain in one sentence why calling something "NoSQL" does not, by itself, say which data model it uses.
Done when: the explanation correctly states NoSQL is a label for several different models, not one model.
Hint
NoSQL only says a database is not relational; it says nothing about which of the several other models it uses.
Easy 3: Shape flexibility (15 minutes)
Explain why product reviews, which can have very different fields from one review to the next, are a natural fit for a document store.
Done when: the explanation correctly ties the varying shape to the document model's flexibility.
Hint
A document store does not require every record to share the same fields.
Medium
Medium 1: Relational or document (25 minutes)
The bookstore's orders table always has exactly the same columns for every order. Explain why this makes orders a poor candidate for a document store, compared to product reviews.
Done when: the explanation correctly notes the stable, uniform shape as the reason relational fits better here.
Hint
A uniform, predictable shape across every row is exactly what a relational table's fixed schema is built for.
Medium 2: Why a graph database for recommendations (25 minutes)
Explain why "customers who bought this book also bought" is a query that follows relationships, and why a graph database is built specifically to answer that kind of query well.
Done when: the explanation correctly identifies the query as relationship-following, matching the graph model's strength.
Hint
The query is about which books connect to which other books through shared buyers, which is a relationship-following question.
Medium 3: Combining two stores (25 minutes)
Describe a realistic bookstore feature that would use both a relational database and a key-value store together, and what each one would be responsible for.
Done when: a concrete feature is described with each store's responsibility stated separately.
Hint
The relational database could hold the order history permanently, while the key-value store holds only the current in-progress cart for fast access.
Hard
Hard 1: Picking the wrong tool on purpose (30 minutes)
Describe what would go wrong, concretely, if a shopping-cart cache (ideal for a key-value store) were instead built as a full relational table with joins across several related tables.
Done when: a concrete cost is named, such as unnecessary query complexity or latency for a lookup that should be a single simple operation.
Hint
Reading a cart through several joined tables adds latency and complexity for what should be a single, fast, key-based lookup.
Hard 2: A column-family store for the bookstore (35 minutes)
Describe a bookstore feature, if the bookstore had millions of customers, that would specifically benefit from a column-family store's write-and-scan strengths, rather than a relational table.
Done when: a feature involving very high write volume or wide-scan access is described, with the column-family fit explained.
Hint
Logging every page view or every search query, at a scale of millions of rows per day, fits a column-family store's write-heavy, scan-friendly design.
Hard 3: Judging a NoSQL decision after the fact (40 minutes)
A team chose a document store for its order data because "NoSQL scales better," then found itself writing complex application code to join orders against customers that a relational database would have done natively. Diagnose what went wrong with the original decision.
Done when: the diagnosis correctly identifies that the access pattern (joins across related, uniformly shaped data) did not match the data model chosen, regardless of any general scaling reputation.
Hint
The team picked based on a general reputation for scaling, not on the actual access pattern, which needed exactly the kind of relational joins the chosen model was weak at.