A friendly illustrated guide to designing and implementing your first database.
Grokking Relational Database Design makes the principles of designing relational databases approachable and engaging. Everything in this book is reinforced by hands-on exercises and examples.
In Grokking Relational Database Design, you’ll learn how to:
Query and create databases using Structured Query Language (SQL)
Design databases from scratch
Implement and optimize database designs
Take advantage of generative AI when designing databases
A well-constructed database is easy to understand, query, manage, and scale when your app needs to grow. In Grokking Relational Database Design you’ll learn the basics of relational database design including how to name fields and tables, which data to store where, how to eliminate repetition, good practices for data collection and hygiene, and much more. You won’t need a computer science degree or in-depth knowledge of programming—the book’s practical examples and down-to-earth definitions are beginner-friendly.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
# Grokking Relational Database Design — Reading Guide
## 【One-Line Pitch】
A beginner-friendly, hands-on introduction to relational database design that walks you from SQL basics through entity-relationship modeling and normalization, ending with a practical demonstration of using generative AI to accelerate the design process. Ideal for self-taught programmers, students, and professionals who need to build their first database without a computer science background.
## 【Book Arc】
- **Opening (~0%–9%)**: Introduces relational databases and SQL fundamentals, including data types (numeric, string, date/time, binary) and basic querying. Establishes the motivating example of The Sci-Fi Collective, an online store whose spreadsheet-based data management breaks down as the business grows.
- **Early (~9%–26%)**: Covers creating tables, managing related tables with primary and foreign keys, and enforcing referential integrity. Demonstrates how foreign key constraints prevent invalid data and how joins combine related tables. Introduces SQL aggregate functions like SUM and discusses performance optimization through indexing.
- **Early (~26%–35%)**: Moves into the database design process itself—requirement gathering through interviews, analysis and design phases, and implementation/testing. Emphasizes identifying database goals, studying existing workflows, and resisting the temptation to copy flawed legacy database structures.
- **Middle (~35%–48%)**: Dives into entities and attributes: naming conventions (singular vs. plural, snake case), identifying candidate keys and choosing primary keys, and selecting appropriate data types (CHAR vs. VARCHAR vs. TEXT, INT vs. BIGINT, DECIMAL for money). Notes inconsistencies across RDBMS implementations.
- **Middle (~48%–52%+)**: Introduces entity-relationship (E-R) diagrams using Crow's Foot notation, explains cardinality (one-to-many, many-to-many), distinguishes strong vs. weak entities, and shows where to place foreign keys (on the many side). Covers normalization principles and practical implementation.
- **Late (~52%–100%)**: Walks through the complete process of designing a database from scratch with the assistance of ChatGPT, demonstrating how generative AI can streamline workflows and enhance efficiency in database design.
## 【Key Takeaways】
- **SQL is the practical foundation for design understanding** (Early): Even though this is a design book, knowing SQL—data types, CREATE TABLE, INSERT, SELECT with filters—makes design concepts concrete. You can use graphical tools, but SQL literacy helps you verify and debug designs.
- **Foreign keys enforce referential integrity automatically** (Early): The foreign key constraint ensures child table rows reference only valid parent primary keys and prevents inconsistent deletions. Trying to insert a review for a nonexistent product (product_id 3000) triggers an error like "foreign key constraint fails."
- **Requirement gathering is the most underestimated phase** (Early): Interviewing stakeholders (owners, managers, staff, developers) to identify database goals takes time and preparation—decide recording methods, permissions, and interview groupings beforehand. The goal determines every subsequent design decision.
- **Don't copy existing databases** (Early): If an organization hires you to design from scratch, resist basing your design on the old structure—the old database likely embodies the problems you're hired to fix.
- **Consistent naming conventions prevent errors** (Middle): Choose singular or plural table names and stick with them; use snake_case consistently. Edgar Codd used singular names in the 1970s, and OOP conventions reinforce this, but consistency matters more than which convention you pick.
- **Primary key selection follows a simple principle** (Middle): Pick the best candidate key (username, email, phone_number can all be unique), or create a new attribute if no good candidate exists. Numeric IDs are stable, unique, simple, and efficient.
- **Data type choices have performance and accuracy implications** (Middle): Use INT for IDs (BIGINT is overkill for most cases), DECIMAL(7,2) for money (scale 2 for cents), and VARCHAR over TEXT for frequently queried strings. Fewer bytes mean faster SELECT queries.
- **Foreign keys go on the many side of one-to-many relationships** (Middle): The many side can have multiple rows referencing one row on the one side; placing the foreign key on the one side would require impossible extra rows.
## 【Reading Tips】
- **Skim the SQL refresher if you're already comfortable** (~0%–9%): The early SQL content is foundational but basic; focus instead on how SQL concepts (data types, constraints) inform design decisions later.
- **Deep-read the requirement gathering and interview sections** (~26%–35%): These practical tips—how to prepare interviews, what questions to ask, how to identify subjects and relationships—are directly applicable to real projects and rarely covered this concretely elsewhere.
- **Work through the entity and data type chapters with the sample data** (~35%–48%): The book's method—check requirements, identify attributes, choose types—is best learned by doing. Download the chapter scripts from the GitHub repository (github.com/Neo-Hao/grokking-relational-database-design) and follow along.
- **Pay close attention to the E-R diagram and cardinality sections** (~48%–52%): Crow's Foot notation and the "foreign key on the many side" rule are the most technically dense parts; re-read if needed and practice drawing diagrams for the example entities.
- **Read the final AI-assisted design part for workflow ideas** (~52%–100%): The ChatGPT demonstration shows how to accelerate design, but treat it as a complement to—not a replacement for—understanding the fundamentals.
## 【Coverage Limits】
This guide covers the book's core content through the middle sections on E-R diagrams and relationships. The excerpts do not cover the full normalization details, the complete AI-assisted design walkthrough, or the final implementation and testing phases in depth.
##
Page 15
of code from the liveBook (online) version of this book at https://livebook.manning.com/book/grokking-relational- database-design. The complete code for the...
tween the two tables is summarized in the following figure: The product_id column is shared by the product and review tables. In the product table, the produ...
ies (such as employee). Other developers followed his lead. Singular names are best used with primary entities (such as a single employee table). Singular ap...
uire accuracy, so you should think about using DECIMAL. For money, it makes sense for the scale to be 2 because that’s the smallest unit of money (cents). In...
distinct name and a data type that defines the kind of data it stores. You may wonder who decides whether something should be considered a single concept, en...
d MySQL Workbench. in the GitHub repository (https://github.com/Neo-Hao/grokking-relational-database- design). You can navigate to the chapter_07 folder and...
the fact that a dealer or customer can be anywhere on Earth. Both customer and dealer have a phone_number attribute. The data length CHAR(15) may not be suff...
e of Brand: brand Attributes: Name: name - VARCHAR(100)…… (This is an excerpt. Full text can be found at https://bit.ly/grdb.) Relationships: “”” brand |...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Loading comments...
Reply to Comment
Edit Comment