12 WIP: When Relational Isn’t Enough
Everything in this book up to this point has been about relational databases. And for good reason: the relational model is the dominant paradigm in data management, it has been for 50 years, and the overwhelming majority of business data still lives in relational systems. If you understand relational thinking, you understand the foundation of most data work.
But the relational model isn’t the only model, and it isn’t the right model for every problem. Starting around 2005, a wave of web-scale companies — Google, Amazon, Facebook, Twitter — ran into situations where relational databases couldn’t keep up. Not because the theory was wrong, but because the engineering trade-offs baked into relational systems — strong consistency, rigid schemas, row-oriented storage — were the wrong trade-offs for what these companies needed.
The result was a new generation of database systems, collectively called NoSQL, each making different trade-offs to handle different types of data at different scales. Understanding these systems — not in technical depth, but conceptually — is part of what it means to be a data-literate business professional today. You’ll encounter these systems in the wild, you’ll work with teams who use them, and you’ll need to reason about when they’re the right choice.
This chapter explains the limits of the relational model, introduces the major NoSQL data models, shows how JSON has found its way back into relational databases, and gives you a framework for deciding which data model to use when.
12.1 The Limits of the Relational Model
The relational model is excellent at what it was designed to do: store structured, interrelated business data with strong integrity guarantees and flexible querying. For a concert ticketing system, a university enrollment system, or an e-commerce order database, it’s hard to beat.
But several categories of problems push against its design assumptions.
When schemas change too fast
The relational model assumes you know what your data looks like before you store it. Tables have defined columns with defined types. Adding a column requires a schema migration. Changing a column’s type or removing one can break existing queries. The schema is a contract, and changing the contract is expensive.
This is fine for stable business domains — a concert ticketing system’s data model doesn’t change much from year to year. But consider a product catalog for a large e-commerce platform. A laptop has RAM, storage, processor speed, and screen resolution. A shirt has size, color, material, and sleeve length. A book has author, ISBN, genre, and page count. None of these share the same attributes.
You could model this relationally with a “product” table containing every possible attribute, most of which are NULL for any given product. You could use a “key-value attributes” table that stores arbitrary attribute names and values. Neither approach is elegant, and both make querying harder.
When the shape of your data varies widely from record to record, and when new types of records are added frequently, the fixed-schema assumption of the relational model creates friction.
The impedance mismatch
Modern software is built with object-oriented languages. A User object in Python or JavaScript has a name, an email, a list of preferences, a profile photo, and a history of recent actions — some of which are themselves objects. Storing this in a relational database requires mapping that nested, hierarchical structure into flat, two-dimensional tables.
This mapping — called the object-relational impedance mismatch — is a constant source of complexity in software development. Converting between the object model your code uses and the table model your database stores is boilerplate work that doesn’t add business value. Entire libraries (called ORM, for Object-Relational Mapping) exist solely to manage this translation.
Document databases, which store data as self-describing JSON-like objects, eliminate most of this friction. Your application objects and your database objects have the same shape.
When joins become too expensive at scale
The relational model’s strength — flexibility through joins — becomes a weakness at extreme scale. A JOIN operation, at its core, compares values from two sets of data to find matches. For tables with millions of rows, this is fast. For tables with billions of rows distributed across hundreds of servers, it can be prohibitively slow.
Distributing a relational database across multiple machines is genuinely hard. A JOIN across two tables stored on different servers requires coordination — transferring data between servers, synchronizing clocks, maintaining consistency. The engineering complexity is enormous.
Some NoSQL systems sidestep this by simply not supporting joins. Instead, they encourage you to denormalize data — to store it in the shape it will be queried. This trades storage efficiency and update complexity for read speed at scale.
Why NoSQL emerged — and what problem it was solving
The NoSQL movement emerged around 2009, driven largely by the needs of web-scale consumer companies. Google, Amazon, and Facebook were handling data volumes and request rates that no existing relational database could sustain. They built new systems tailored to their specific problems.
Google built Bigtable for storing web index data — optimized for massive parallel reads and writes, not for joins. Amazon built Dynamo for shopping cart data — optimized for high availability and fast reads, willing to accept eventual consistency. Facebook built Cassandra for inbox data — optimized for write-heavy workloads across many machines.
“NoSQL” doesn’t mean “no SQL language” (many of these systems have SQL-like query languages). It means “not only SQL” — a recognition that SQL and the relational model are one tool among several, appropriate for some problems but not all.
Crucially, the choice of a NoSQL database is always a trade-off. These systems achieve their performance and scale advantages by relaxing guarantees that relational databases provide. Understanding what you’re giving up is as important as understanding what you’re gaining.
12.2 NoSQL Data Models
There are four major families of NoSQL databases, each with a distinct data model. They’re not competitors so much as tools designed for different jobs.
Document stores: data as self-describing objects
A document store saves data as documents — self-contained objects that describe themselves, typically in JSON format. Each document can have a different structure. There are no fixed columns; a document contains whatever fields it has.
A user document in a concert platform might look like:
{
"user_id": "u_8842",
"username": "maya_j",
"email": "maya@mu.edu",
"subscription": "premium",
"signup_date": "2025-09-01",
"preferences": {
"genres": ["indie rock", "folk", "hip-hop"],
"notifications": true,
"dark_mode": true
},
"recent_searches": [
"Tyler Childers",
"Wet Leg",
"Hozier"
],
"saved_concerts": ["c_441", "c_512", "c_603"]
}
This document is self-describing. You don’t need to consult a schema definition to know what preferences.genres means — it’s right there in the structure. And another user’s document could have different fields — maybe they have premium_since or billing_address — without breaking anything.
When documents are the right unit. Document stores work best when:
- Each record is relatively self-contained (you retrieve it as a unit, not by joining it to other records)
- The structure varies between records
- You read the whole object far more than you query into its parts
- The object maps naturally to a structure your application already uses
User profiles, product catalogs, blog posts, and configuration data are classic document store use cases. Each item is a whole thing — you fetch a user profile, you display a product listing — and you don’t often need to query across the internal fields of many documents at once.
MongoDB is the most widely used document database. Many applications use it for the parts of their data that are flexible or object-shaped, while using a relational database for the parts that are structured and interrelated.
The trade-off. Document stores sacrifice some of the relational model’s strengths. There’s no referential integrity — nothing stops you from saving "saved_concerts": ["c_441", "c_99999"] where c_99999 doesn’t exist. There’s no join operation — to get all the details about a saved concert, you need to look up each one separately or store the details redundantly inside the user document. And because documents are schema-free, your application code has to handle the possibility that a field might be missing or have an unexpected type.
Key-value stores: simplicity at extreme scale
A key-value store is the simplest possible data model: a dictionary. Every piece of data has a key (a unique identifier) and a value (anything at all — a string, a number, a blob, a serialized object). You can look up a value by its key. That’s essentially it.
Key: "session:user_8842" Value: {"logged_in": true, "cart": [...], "last_active": "2026-04-01T14:22:00"}
Key: "leaderboard:week_14" Value: [{"user": "maya_j", "score": 8400}, {"user": "mlee", "score": 7200}, ...]
Key: "song:1042:metadata" Value: {"title": "Espresso", "artist": "Sabrina Carpenter", "duration": 174}
What you give up: you can only look things up by key. There’s no filtering, no joining, no aggregating. You can’t ask “find all sessions where last_active was more than 30 minutes ago” without pulling every session key, fetching every value, and filtering in your application code.
What you get: extremely fast reads and writes at enormous scale. Key-value stores can handle hundreds of thousands of operations per second with millisecond response times, because the data model is so simple that the database doesn’t have to do much work.
Use cases: session storage (retrieving a user’s session data when they make a request), caching (storing the result of an expensive database query so the next request can skip it), leaderboards and counters (incrementing a score or count atomically), rate limiting (tracking how many API requests a user has made in the last minute).
Redis is the most popular key-value store and is nearly ubiquitous as a caching layer. Most large applications use Redis alongside a relational or document database: the relational database is the source of truth, Redis stores frequently-accessed data in memory for speed. When Spotify loads your Discover Weekly playlist, they’re probably reading from a fast cache, not directly querying the relational database that stores your listening history.
Graph databases: when relationships are the data
In a relational database, relationships between records are represented with foreign keys and resolved with joins. For most business data, this is fine — you have a moderate number of entities and relationships, and joins are efficient.
But some problems are fundamentally about the web of connections between things, not the things themselves. In these problems, the relationship is the data, and traditional joins become impractical.
Nodes and edges. A graph database stores data as nodes (things) and edges (connections between things). Both nodes and edges can have properties.
Consider a social network like Instagram. The interesting data isn’t really the users — it’s who follows whom, who liked what, which posts are connected to which accounts, which hashtags appear on which posts. The queries that matter are: “Show me posts from people this user follows,” “Who are the people two hops away from this account?” “Detect accounts that are following each other in suspicious patterns.”
In a graph database, this is expressed naturally:
Node: User {id: "maya_j", name: "Maya Johnson"}
Node: User {id: "mlee", name: "Marcus Lee"}
Edge: FOLLOWS {from: "maya_j", to: "mlee", since: "2025-10-01"}
Edge: FOLLOWS {from: "mlee", to: "maya_j", since: "2025-10-03"}
Finding all users within two hops of Maya is a graph traversal — a natural operation for a graph database. In a relational database, you’d need a join to find Maya’s direct follows, then another join (or a recursive query) to find their follows, and the performance degrades badly as the network gets larger and the paths get longer.
Use cases: social networks (who follows whom, friend recommendations), fraud detection (detecting rings of accounts that transfer money to each other), recommendation engines (finding items similar to what a user liked, based on what similar users liked), knowledge graphs (mapping relationships between concepts, entities, and facts).
The trade-off. Graph databases are optimized for traversal queries (following connections through a network) and less efficient for the broad, tabular queries that relational databases handle well. You wouldn’t use a graph database to generate a monthly revenue report.
Columnar stores: optimized for analytical reads
Everything we’ve discussed so far — relational databases, document stores, key-value stores, graph databases — stores data row by row. When you INSERT a row, the database writes all of that row’s columns together. When you retrieve a row, you get all its columns back at once.
This is optimal for transactional workloads where you need entire records: retrieve this customer, update this order, insert this ticket. But it’s inefficient for analytical workloads where you need one column across millions of rows.
Consider: “What is the average listening duration per genre across all streams this year?” This query touches the seconds_listened column and the genre column (via a join) across every row in the Stream table. In a row-oriented database, retrieving those two columns means loading every row from disk and discarding everything else — potentially reading terabytes of data you don’t need.
A columnar store (also called a column-oriented database) stores data column by column rather than row by row. All the values for seconds_listened are stored together. All the values for genre are stored together. To run an aggregation on those two columns, the database reads only those columns — skipping everything else.
This makes columnar stores dramatically faster for analytical queries, especially aggregations over large datasets. They also compress extremely well: a column of repeated values (“free,” “premium,” “student”) compresses to a tiny fraction of its uncompressed size.
Snowflake, Amazon Redshift, Google BigQuery, and Databricks are examples of columnar systems used for analytics and data warehousing. These are the systems that power business intelligence dashboards, executive reports, and data science workloads.
The trade-off. Columnar stores are slow for row-oriented operations. Updating a single row requires touching every column file where that row has a value. They’re generally not used for transactional workloads where you’re inserting and updating individual records thousands of times per second. They’re designed for the opposite: infrequent large-scale reads.
12.3 JSON in a Relational World
Here’s an interesting development: relational databases, which were originally built for structured, schema-fixed data, have added native support for JSON — the semi-structured, flexible format that document databases are built around.
PostgreSQL, MySQL, SQL Server, SQLite, and Oracle all support JSON columns. You can store a JSON document inside a column of a relational table, and you can query into its contents using SQL.
This means the line between “relational database” and “document database” has blurred considerably. Many applications that used to require a dedicated document database can now store flexible, document-shaped data inside their existing relational database, using JSON columns.
Semi-structured data in modern relational databases
A JSON column stores arbitrary JSON data — objects, arrays, nested structures — inside a single column of a relational table.
CREATE TABLE User (
user_id INT NOT NULL PRIMARY KEY,
username VARCHAR(100) NOT NULL UNIQUE,
email VARCHAR(255) NOT NULL UNIQUE,
subscription VARCHAR(20) NOT NULL,
preferences JSON, -- flexible JSON column
signup_date DATE NOT NULL
);
The preferences column can contain different data for each user:
INSERT INTO User (user_id, username, email, subscription, preferences, signup_date)
VALUES (
1,
'maya_j',
'maya@mu.edu',
'premium',
'{"genres": ["indie rock", "folk"], "notifications": true, "dark_mode": true}',
'2025-09-01'
);
Querying inside a JSON column with SQL
Modern databases provide operators for querying into JSON content. The exact syntax varies by database, but the concept is the same: navigate into the JSON structure and extract values.
In PostgreSQL:
-- Find all users who have dark_mode enabled in their preferences
SELECT username, email
FROM User
WHERE preferences->>'dark_mode' = 'true';
-- Find all users who list 'folk' as a preferred genre
SELECT username
FROM User
WHERE preferences->'genres' ? 'folk';
In MySQL:
-- Extract a specific preference value
SELECT username, JSON_EXTRACT(preferences, '$.dark_mode') AS dark_mode
FROM User;
The -> and ->> operators in PostgreSQL navigate into JSON objects. preferences->>'dark_mode' extracts the value of the dark_mode key as text. preferences->'genres' extracts the genres array as a JSON value.
When to use JSON columns and when to normalize instead
JSON columns are powerful but easy to misuse. The right question is: does this data have a stable, known structure that will be queried predictably? If yes, normalize it. If no, JSON might be appropriate.
Use JSON columns when:
- The structure genuinely varies between rows, and you can’t predict what fields will appear
- The data is written and read as a unit — you’re not often filtering or joining on individual fields within it
- The content is configuration, preferences, or metadata that doesn’t need integrity enforcement
- You’re storing event data or logs where each event type has different properties
Normalize instead when:
- You need to filter, sort, or join on values inside the JSON
- You need integrity enforcement (NOT NULL, UNIQUE, FK) on individual fields
- The structure is actually consistent — every record has the same fields
- The data will be analyzed in aggregate (aggregating inside JSON is awkward and slow)
A practical example: user preferences (dark mode, notification settings, UI customizations) are a good candidate for a JSON column — they vary between users, they’re read and written as a unit, and you rarely need to query “show me all users with dark mode enabled.” But a user’s subscription history — when they subscribed, at what tier, when they canceled — should be a normalized table, because you’ll want to join, filter, and aggregate it.
The danger: losing integrity guarantees inside JSON
When data goes into a JSON column, it leaves the world of constraints. The database doesn’t enforce NOT NULL on fields inside JSON. It doesn’t enforce CHECK constraints. It doesn’t enforce referential integrity. Any value can go in; the database treats it all as opaque text (with structure, but no guarantees about what’s inside).
This is the fundamental trade-off: flexibility vs. integrity. A JSON column gives you schema flexibility; it takes away the database’s ability to enforce rules about what’s inside.
This is fine for genuinely flexible data. It’s dangerous for data that looks flexible but actually has rules. If every user’s preferences JSON is supposed to have a notifications field that’s either true or false, and someone stores "notifications": "maybe" or forgets the field entirely, the database won’t complain. Your application code has to handle the inconsistency.
The principle: JSON columns are not a way to avoid schema design. They’re a tool for data that genuinely doesn’t fit a fixed schema. Use them deliberately, not as a default.
12.4 Choosing a Data Model
With multiple data models available, how do you decide which one to use? The answer depends on the nature of your data, the queries you’ll need to run, and the scale at which you’re operating.
A decision framework: relational vs. NoSQL
Ask these questions:
How structured is the data?
If every record has the same fields and those fields are well-defined, relational is the natural fit. If records vary significantly in structure and you can’t fully define the schema in advance, a document store or JSON columns might be appropriate.
What queries will dominate?
If you need to filter on individual fields, join across entities, and aggregate across rows, relational is your best tool. If you primarily retrieve complete objects by a known key, a key-value or document store might be faster and simpler. If your most important queries follow connections through a network of relationships, a graph database is designed for exactly that.
What scale do you need?
For a database with millions of rows accessed by hundreds of users, a well-tuned relational database will handle it fine. For a system handling billions of records across thousands of concurrent users — social media feeds, global e-commerce, real-time multiplayer games — NoSQL systems may be necessary. But don’t optimize prematurely: most applications never reach a scale where relational databases are insufficient.
How strong are the consistency requirements?
Relational databases with ACID transactions provide strong consistency guarantees. Many NoSQL systems trade consistency for availability and speed, accepting that different users might temporarily see different versions of the same data. If you’re storing financial transactions, medical records, or anything where inconsistency has serious consequences, the relational model’s guarantees matter.
How often does the schema change?
If your data model is stable, relational schemas are fine — migrations are occasional. If your application evolves rapidly and the shape of your data changes frequently, a more flexible model reduces friction.
Default to relational; deviate with a reason
The most important advice for data model selection: start with the relational model. It is well-understood, well-supported, widely known, and correct for the vast majority of business problems. The expertise to design, query, and maintain it is widely available. The tooling is mature.
Adopt a NoSQL system when you have a specific, identified problem that relational databases don’t solve well — not because NoSQL sounds modern or because you’ve heard big tech companies use it. Using a graph database for data that isn’t graph-shaped, or a document store for data that’s actually well-structured, adds complexity without the corresponding benefit.
This principle — “use the simplest tool that solves the problem” — applies beyond databases. The appeal of new technology is real, but the cost of using the wrong tool is also real: harder to hire for, harder to maintain, harder to query with standard tools, and harder to integrate with the rest of your data ecosystem.
Polyglot persistence: using multiple models together
Modern applications commonly use more than one database system, each chosen for a specific purpose. This approach is called polyglot persistence — using multiple data storage technologies in parallel.
A typical large application might use:
- A relational database (PostgreSQL, MySQL) for core business data: users, orders, transactions, structured records that need integrity guarantees
- A document store (MongoDB) for product catalog data or user-generated content with flexible structure
- A key-value store (Redis) for caching, sessions, and real-time counters
- A columnar warehouse (Snowflake, BigQuery) for analytical queries, dashboards, and reporting
- A search engine (Elasticsearch) for full-text search and fuzzy matching
These systems don’t replace each other — they specialize. Data from the relational database might be synchronized to the warehouse for analysis. Frequently accessed relational data might be cached in Redis. User content stored in MongoDB might be indexed in Elasticsearch for search.
This is the modern data landscape: not one database to rule them all, but a collection of specialized tools, each doing what it’s best at.
The data professional’s role
In this environment, the data professional’s job is to understand the trade-offs well enough to have informed conversations about data architecture. You don’t need to be an expert in every NoSQL system. You do need to be able to ask the right questions:
- What kind of data is this? How structured? How variable?
- What queries are most important? What’s the access pattern?
- What consistency and integrity guarantees do we need?
- What scale do we expect?
- What expertise do we have on the team to operate this system?
The relational model you’ve been learning throughout this book is the lens through which you evaluate everything else. Understanding what relational databases do well and why helps you recognize the situations where a different model might serve better — and why.
Chapter Summary
The relational model is excellent for structured, interrelated business data with well-defined schemas, integrity requirements, and flexible querying. But it faces three main pressures: schemas that change frequently, the impedance mismatch between object-oriented code and flat tables, and the cost of joins at extreme scale.
NoSQL is not one thing — it’s a family of systems, each with a different data model suited to different problems. Document stores (MongoDB) handle varying-structure records that are retrieved as units. Key-value stores (Redis) provide extremely fast access by key, at the cost of losing every other query capability. Graph databases model networks of relationships where connections are as important as the data itself. Columnar stores (Snowflake, BigQuery) are optimized for analytical reads across huge datasets by storing columns together rather than rows.
JSON columns in relational databases have blurred the line between relational and document models, allowing flexible, schema-free data to coexist with structured, constraint-enforced data in the same system. JSON columns are appropriate for genuinely variable data; they’re not a substitute for normalization when the data has a stable structure.
Choosing a data model means asking about structure, query patterns, scale, consistency requirements, and schema stability. Default to relational; adopt NoSQL when you have a specific, identified reason. Modern applications often use multiple data storage systems in parallel — polyglot persistence — with each system chosen for its strengths.
The relational thinking you’ve developed throughout this book transfers directly to evaluating these trade-offs. Understanding what relational databases do well tells you exactly what you give up when you move away from them.
Key Terms
NoSQL — A family of database systems that do not use the relational model. “Not only SQL” — they may or may not support SQL syntax, but they make different trade-offs than relational databases to handle specific classes of problems.
Object-relational impedance mismatch — The friction that arises from mapping between object-oriented application code (nested, hierarchical objects) and flat relational tables. A key motivation for document databases.
Document store — A NoSQL database that stores data as self-describing documents (typically JSON). Each document can have a different structure. Examples: MongoDB, Couchbase.
Key-value store — A NoSQL database with the simplest possible data model: every piece of data has a key and a value. Only key-based lookups are supported. Examples: Redis, Amazon DynamoDB (in key-value mode).
Graph database — A NoSQL database that stores data as nodes (things) and edges (connections between things). Optimized for traversal queries through networks of relationships. Examples: Neo4j, Amazon Neptune.
Columnar store — A database that stores data column by column rather than row by row. Dramatically faster for analytical queries that scan a few columns across many rows. Examples: Snowflake, Google BigQuery, Amazon Redshift.
JSON column — A column in a relational database that stores JSON data. Provides document-like flexibility within a relational schema, at the cost of losing constraint enforcement on the JSON contents.
Polyglot persistence — The practice of using multiple database systems within a single application, each chosen for its strengths with a specific type of data or query pattern.
Caching — Storing the result of an expensive operation (such as a database query) in a fast-access store (like Redis) so that future requests can retrieve it quickly without repeating the original operation.
Eventual consistency — A consistency model used by some NoSQL systems in which updates propagate to all nodes over time, but different nodes may temporarily return different values for the same data. Contrasts with the strong consistency of ACID-compliant relational databases.
Interactive Activities
The activities below are designed to be completed with a generative AI tool such as Claude (claude.ai) or ChatGPT. For each activity, copy the prompt in the gray box and paste it directly into your AI tool to begin an interactive study session.
Activity 12.1 — Concept Check: NoSQL Data Models
This activity checks your understanding of the key ideas from Chapter 12. The AI will quiz you one question at a time and give feedback after each answer.
Copy and paste this prompt into your AI tool:
I’ve just finished reading Chapter 12 of my Introduction to Databases textbook, which covered the limits of the relational model, four types of NoSQL databases (document stores, key-value stores, graph databases, and columnar stores), JSON columns in relational databases, and how to choose between data models. I want to check my understanding. Please quiz me by asking the following questions one at a time. Wait for my answer before moving on. After each answer, tell me what I got right, correct anything I misunderstood, and ask if I’d like to go deeper before moving to the next question.
Here are the questions:
- What is the object-relational impedance mismatch, and why did it motivate the development of document databases?
- What is a document store? How does it differ from a relational database? Give an example of data that would be well-suited to a document store.
- What is a key-value store? What can you do with it, and what can’t you do? Give a real-world use case.
- What makes graph databases different from relational databases for relationship-heavy data? Give an example where a graph database is clearly the better choice.
- Why are columnar stores faster for analytical queries than row-oriented databases? What are they slower at?
- What is a JSON column in a relational database? When is it appropriate to use one, and when should you normalize instead?
- What is polyglot persistence? Give an example of an application that might use three different types of databases for three different purposes.
- The chapter says “default to relational; deviate with a reason.” What does this mean, and why is it good advice?
- What is eventual consistency? How does it differ from the ACID consistency guarantee in relational databases?
Activity 12.2 — Apply It: Match the Problem to the Model
This activity gives you practice selecting the right data model for a given problem. The AI will present scenarios and ask you to justify your choice.
Copy and paste this prompt into your AI tool:
I’m studying database systems beyond the relational model. I want to practice matching real-world problems to the right data model. For each scenario below, I’ll choose from: relational database, document store, key-value store, graph database, or columnar store. I also need to justify my choice — what property of the problem makes this model the right fit?
Please present each scenario one at a time. Ask me to name the data model and explain my reasoning. After my answer, tell me if I’m right, explain why the model fits (or what the actual best choice is), and mention what the closest wrong answer would be and why it doesn’t fit as well. Then ask if I want to discuss it more before moving on.
Scenario 1: A university tracks student enrollment, courses, grades, instructors, and departments. Students enroll in courses, instructors teach courses, and grades are recorded per student per course. The data is very structured and relationships between tables are important.
Scenario 2: A music streaming service needs to store what each user was doing during their last session — what they were playing, their queue, their current position in a song, their search history. This data changes rapidly and must be retrieved in under 10 milliseconds per request.
Scenario 3: A fraud detection system needs to identify rings of credit card accounts that have been sending money to each other in circular patterns. The key operation is: starting from a suspicious account, follow the transaction trail through 3–4 hops to find other accounts in the same ring.
Scenario 4: A large retailer wants to analyze two years of sales data to produce quarterly revenue reports by product category, region, and customer segment. The queries scan billions of rows but only use a few columns at a time.
Scenario 5: A healthcare app stores patient intake forms. Different types of patients fill out different forms — a routine checkup has different fields than an emergency visit or a surgical consultation. New form types are added regularly.
Scenario 6: A social platform where users post content, follow each other, and like or comment on posts. The core feature is a personalized feed showing posts from people you follow, and recommendations for accounts you might want to follow based on who your friends follow.
After we’ve gone through all six, ask me to choose the hardest scenario and explain in detail why the second-best option wouldn’t work as well.
Activity 12.3 — Practice: JSON or Normalize?
This activity builds your judgment about when to use a JSON column and when to normalize data into structured tables.
Copy and paste this prompt into your AI tool:
I’m practicing the decision of when to use a JSON column in a relational database versus normalizing data into structured tables. My textbook says to use JSON when data is genuinely variable in structure and read as a unit, and to normalize when the structure is consistent, when I need to filter or aggregate on specific fields, or when I need integrity constraints.
For each data description below, ask me: (a) Should this be a JSON column or a set of normalized columns/tables? (b) What is the main reason for your choice? (c) What would you lose by making the opposite choice?
Present one at a time, wait for my answer, give feedback, and show what a good schema decision looks like for each one. Move on when I’m ready.
Data 1: User notification preferences — whether they want email alerts, push notifications, and weekly digest emails. Every user has the same three settings.
Data 2: Concert event metadata — for most concerts, you just need a title, date, and venue. But some concerts also have age restrictions, parking information, accessibility notes, sponsor listings, and set times for each performer. Different concerts have very different supplemental information.
Data 3: Song royalty rates — each song has a songwriter royalty rate (a percentage), a performance royalty rate, and a mechanical royalty rate. These are used in financial calculations every month.
Data 4: A webhook log — each time an external service calls your API, you log the raw JSON payload they sent. Every webhook has a different structure depending on which service sent it.
Data 5: Student demographic information — name, date of birth, home state, and first-generation college student status (true/false). Every student record has the same fields.
Data 6: Product specifications for a marketplace that sells furniture, electronics, clothing, and sporting goods — each product category has completely different attributes (dimensions/material/assembly for furniture; processor/RAM/storage for electronics; size/color/fabric for clothing).
After all six, summarize the pattern: when does the “JSON column” choice clearly win, and when does it clearly lose?
Activity 12.4 — Case Study: Design the Data Stack
This activity asks you to design a multi-system data architecture for a realistic application. The AI will play a technical lead guiding you through the decisions.
Copy and paste this prompt into your AI tool:
I want to practice designing a multi-database architecture for a realistic application. You’ll play the role of a senior data architect named Alex at a company called StreamU — a campus-focused music streaming platform similar to Spotify but just for college students. I’m a junior data analyst presenting my proposed database architecture.
Here’s the application we’re designing for:
StreamU has 500,000 student users across 200 universities. Students stream music, create playlists, follow other users, and get personalized song recommendations. The platform tracks every stream event for royalty calculation and analytics. Students can also review and rate songs. The company runs weekly reports on the most-streamed songs, top genres per school, and revenue by subscription tier.
Please guide me through these design decisions one at a time, in the style of a technical interview. For each decision, ask me what database system I’d use and why. Push back with follow-up questions if my reasoning is incomplete or if I’m not thinking through the trade-offs. Here are the decisions:
- What database system should we use for core user data (accounts, subscriptions, payment records)?
- What should we use for storing user preferences, listening history snapshots, and UI settings — data that varies in structure and is read frequently per user?
- We need to serve personalized recommendations based on what similar users listen to. What system is best suited for “users who liked X also liked Y” relationships?
- Every stream generates an event record. We get 2 million streams per day. Where should those events be stored for real-time royalty tracking, and where for historical analytics and reporting?
- Our platform needs to serve a user’s current playback state (what song, what position, what device) in under 5 milliseconds. Where does this live?
After the five decisions, step out of character and give me honest feedback: Which decisions did I make well? Where did I miss a trade-off? Would you hire me as a data analyst based on this conversation?