</> MAANG.io
system design · 201

Intermediate

Master system design interviews with scalable architecture patterns, distributed systems, and real-world design challenges.

0/124 solved 0% complete

SQL & Data Modeling

maang.io System Design Series


Good data modeling is the foundation of every relational system. This deep dive covers the relational model — keys, normalization (1NF→BCNF) to remove anomalies, indexes (B+trees) that change query plans, and joins — plus when to deliberately denormalize for performance. Get the model right and everything downstream is easier.

This deep dive comes in three parts:

  • Foundations & Core Concepts — relations, keys, and normalization.
  • Internals — B+tree indexes, join strategies, and denormalization trade-offs, with worked numbers.
  • Interview — Staff/Principal Q&A: schema design, indexing, and normalize-vs-denormalize.

SQL & Data Modeling — Part 2: Internals & Execution

maang.io System Design Series


What is this?

Back to our town library. In Part 1 we filed every fact onto exactly one card. Now watch what a great librarian actually does when you ask for a book. They don't walk two million shelves — that would take all day. They go to the catalog drawer, whose cards are sorted, and use the sorted structure to jump near the right card in a handful of steps, then walk a few cards to the exact one. And when you ask them to match "every order card against its customer card," they don't compare all cards against all cards; they pick a strategy based on how big each drawer is and whether either is already sorted.

That catalog drawer is a B+tree index, the jump-in-a-handful-of-steps is its logarithmic depth, and the matching strategy is a join algorithm chosen by the query planner. This chapter is the machinery that makes the clean-but-split schema from Part 1 fast to read.

The one-line idea: a relational engine keeps a B+tree beside each indexed column so lookups and range scans are logarithmic instead of linear, and a cost-based query planner uses table statistics to pick how to execute your declarative query — which index to use, which join algorithm, in which order — so the same SELECT can run in microseconds or minutes depending on the plan it chooses.

Let's build it up: the index structure, the read path through the planner, the join algorithms, the write path, then the deliberate decision to denormalize.


Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.