Two Shapes of Data
The same information, a student, their enrolments, their progress, can be modelled two fundamentally different ways before a single query is ever written. Which shape you choose decides how easy certain questions are to ask later, and how easy the data is to change without breaking anything.
Relational: Shape Enforced, Related by Joins
A relational (SQL) database stores data in tables with a fixed schema: every row in students has the same columns, every row in enrolments has the same columns, and the two are connected by a foreign key (student_id) rather than being stored together. Reading "this student and all their enrolments" means a join, matching rows across tables at query time. The payoff is that the shape is enforced centrally: you cannot accidentally save a student record with a typo'd column, and you can ask new, unanticipated questions (which courses have the lowest completion rate across all students) without redesigning anything, because the relationships are explicit and queryable.
Document: Related Data Stored Together
A document (NoSQL) database instead stores one entity and the data that naturally belongs with it as a single self-contained document. A student's enrolments might live directly inside their own document as an embedded list. Reading "this student and all their enrolments" is now a single lookup by ID, no join required, which is fast and simple for exactly that access pattern. The cost shows up when you need to query across the embedded data in a way it was not shaped for, finding every enrolment in a specific course now means scanning every student document rather than querying one focused table.
"NoSQL" Is Bigger Than Documents
This lesson uses "document database" as the NoSQL example because it is the clearest contrast with relational, but NoSQL is really an umbrella term for several different shapes, not a synonym for "document store." A key-value store (Redis is the example you already met in Module 1's caching lesson) trades away structure entirely for raw speed on simple lookups. A columnar store is built for scanning one column across billions of rows fast, the shape analytics and reporting workloads want. A graph database makes relationships themselves first-class, which pays off when the interesting question is about connections (who knows whom, what links to what) rather than records. Document stores are the shape most often compared to relational tables because they are the most direct substitute, but assuming "NoSQL" always means "document" will leave you reaching for the wrong tool the moment the access pattern isn't a lookup-by-ID.
Choosing Between Them
The honest version of this decision is not "SQL is old, NoSQL is modern" or the reverse, it is about your access pattern and your consistency needs.
- Reach for relational if your data has many relationships you will query in different, unpredictable directions, and you need strong guarantees that related rows stay consistent (Module 3's next lesson, ACID transactions, depends on this).
- Reach for a document store if you have a clear, dominant access pattern (fetch this one entity and everything embedded in it, fast, at huge scale) and can tolerate eventual consistency between documents.
Key Takeaway Most systems with highly interconnected, frequently-reshaped data, a course catalogue, enrolments, payments, user accounts, reach for a relational model precisely because the relationships between them get queried in many different, unpredictable directions over the system's life, not just the one direction the schema was originally drawn for.