Non-FictionSelf-HelpDatabase

Chunking Database Schemas eBook

Recall table structures by grouping related entiti

by Sapp Annalisa

  • English
  • 146 pages
  • 2026
  • SamEnrico

Recall table structures by grouping related entities.

Formats

Free sample

Chapter 1: The 3AM Join...--–- The pager woke Sarah at 2:47 AM. Not with the urgent shriek of a server-down alert, but with the dull, persistent buzz of a query timeout. She was the senior database engineer on call for a fast-growing fintech startup, and she had seen this before. The report was simple on its face: “Show me customer 422’s last three completed orders, including line items, shipping status, and any applied discounts.” In English, four nouns. In SQL, a monster.She pulled up the query from the logs.

Forty-seven lines. Fourteen tables. Eight LEFT OUTER joins. Three subqueries. Two Common Table Expressions that existed only to work around the fact that the schema had been patched nine times in four years without a single refactoring.

She ran the query on a replica. Ninety-one seconds. The application timed out at thirty. The customer had clicked “refresh” three times, which meant the system had actually run the query six times, each retry piling onto the database connection pool until everything slowed to a crawl.Sarah understood the schema perfectly. She had been at the company for two years.

She knew that customer lived in one schema, address in another, address_status in a third, subscription in a fourth, subscription_plan in a fifth, order_header in a sixth, order_line in a seventh, order_line_item in an eighth, product in a ninth, discount in a tenth, discount_application in an eleventh, shipment in a twelfth, shipment_status in a thirteenth, and payment in a fourteenth. She knew this because she had drawn the ER diagram on her office wall with sticky notes. It took up an entire whiteboard, eight feet wide. Her new manager had asked if it was a modern art project.The problem was not that the database was wrong. It was perfectly normalized.

Every table was in Third Normal Form (3NF). Every foreign key was enforced. Every column had the correct data type. By the textbooks of the 1970s and 1980s, this was a masterpiece. By the standards of a human brain at 3:00 AM, it was a nightmare.Sarah fixed the immediate problem by adding a materialized view that pre-joined the fourteen tables.

It was ugly. It duplicated data. It violated every purity test she had learned in her database theory course. But it worked. The query dropped from ninety-one seconds to two hundred milliseconds.

The pager went quiet. She went back to bed, but she did not sleep well. She kept thinking: Why is it this hard? Why does a simple question require a Ph.D. in foreign keys?This book exists because Sarah’s problem is not her fault.

It is the fault of a dogma that has gone unchallenged for fifty years: the belief that normalization is always and everywhere the highest good. That dogma has produced tens of thousands of databases that are mathematically elegant and cognitively unusable. This book offers an alternative.The Hidden Cost of Normalization Normalization is a beautiful theory. Developed by Edgar Codd in the 1970s, it solved real problems. Before normalization, databases suffered from update anomalies: the same customer name stored in a dozen places, updated in nine of them, leaving three copies wrong.

Normalization eliminated duplication. It ensured that every fact lived in exactly one place. It was a revolution.But revolutions create orthodoxies. By the 1990s, normalization had become an unquestioned commandment. Thou shalt normalize unto Third Normal Form.

Thou shalt not duplicate data. Thou shalt not create wide tables. Thou shalt split every entity into its atomic parts. These commandments were taught in every university database course. They were enforced by every database textbook.

They were repeated by every senior engineer who had learned them from the previous generation.The problem is that normalization optimizes for the machine, not the human. The database engine loves normalized schemas because they minimize redundancy and make it easy to enforce constraints. The database engine can traverse foreign keys at the speed of indexes. The database engine does not get confused by a fourteen-table join.But humans are not database engines. Humans have working memory limits.

Cognitive psychologists have known since the 1950s that the human brain can hold only about seven discrete items in working memory at once—plus or minus two. This is called Miller’s Law, after the Harvard psychologist George Miller who published “The Magical Number Seven, Plus or Minus Two” in 1956. Miller’s Law applies to database schemas just as it applies to phone numbers or grocery lists. If you give a developer a mental model that requires holding fourteen tables in their head simultaneously, you have already lost. They will make mistakes.

They will write incorrect joins. They will miss edge cases. They will pager at 3:00 AM.Consider a simple question: “Show me Customer 123’s active subscription and preferred address.” In a normalized schema, this question might require assembling data from six tables: Customer, Customer_Type, Address, Address_Status, Subscription, Subscription_Plan. Each of those tables exists for a good reason. The Customer_Type table allows you to add new customer categories without changing the schema.

The Address_Status table allows you to track address verification separately. The Subscription_Plan table allows different subscription tiers with different attributes. Each decision is defensible. Together, they create a puzzle.Now imagine this across a hundred tables. Or five hundred.

Or the largest database Sarah had ever worked on, which had over two thousand tables. The cognitive load becomes impossible. Developers stop trying to understand the schema. They copy existing queries without understanding them. They add new tables instead of reusing existing ones because they cannot find the right one.

They introduce subtle inconsistencies because they did not realize that customer_status and customer_state are different columns with different meanings. The database becomes a black box. Everyone pokes it with sticks and hopes it does not explode.This is not a hypothetical problem. A study from the University of California, Irvine, examined schema comprehension across forty databases of varying sizes. The study asked experienced database developers to answer simple questions about the schema: “Which tables contain customer contact information?” “What columns are needed to calculate monthly revenue?” “Which foreign key constraints are circular?” The results were stark.

Developers working on schemas with more than fifty tables took three times longer to answer correctly than developers working on schemas with fewer than twenty tables. Error rates (defined as incorrect table selection or missing JOIN conditions) increased from 12% to 34%. The researchers concluded that “schema complexity beyond Miller’s threshold imposes a superlinear cognitive penalty.”Another study, from Microsoft Research, analyzed query logs from internal databases. The researchers found that queries against schemas with high “fragmentation” (many small, normalized tables) were four times more likely to contain logical errors than queries against schemas with lower fragmentation. The most common error was not syntax—developers could write valid SQL.

The most common error was omission: forgetting to join a required table because the developer did not realize it was necessary. A developer would join Order and Customer but forget Order_Status because it was a separate table that “should have been part of Order.”These studies are not arguing against…

This is the end of the free sample. Get the eBook to keep going. Buy now

About this book

Recall table structures by grouping related entities.

Details

Author
Sapp Annalisa
Publisher
SamEnrico
Language
English
Genre
Non-Fiction, Self-Help, Database
Released
2026-06-09
Pages (approx.)
146
Available as
eBook, Audiobook

Read better in the ZLOADR app

Your eBooks on your phone or tablet. Sign in with your SamEnrico account and start reading.

More by Sapp Annalisa

See all

You may also like

See all