Why Database Design Matters
See how a single messy spreadsheet breaks as data grows, what a database management system adds, and how the relational model organizes data.
Welcome back!
Step 1 of 11Learn
The spreadsheet that grew
A small online bookstore starts by tracking orders in one spreadsheet. Each row has the order number, date, customer name, customer email, customer address, book title, author, price and quantity. It works fine for the first fifty orders.
Then the problems arrive. Ana Ruiz has placed 30 orders, so her address appears 30 times. When she moves, someone updates 28 of the rows and misses 2, and now the shop has two addresses for her and no way to know which is current. A book's price changes, but old rows show the old price, and nobody can tell whether that was intentional. When the last order for a rare book is deleted, the shop loses the only record that it ever stocked that book. Two employees edit the file at the same time and one overwrites the other's changes.
None of these are typing mistakes. They are design mistakes: one table is trying to describe customers, books and orders all at once, so every fact is stored many times. Database design is the discipline of deciding which tables to create, what goes in each one and how they connect, so that each fact is stored once, stays consistent and can be queried easily. A good design is invisible; a bad one causes bugs for years.
Step 2 of 11Practice · Select all that apply
Which problems in the bookstore spreadsheet come from storing the same fact many times? Select all that apply.
Select all that apply.
Step 3 of 11Learn
What a database system adds
A database is an organized collection of data. The software that stores it, enforces its rules and answers questions about it is a database management system (DBMS), such as PostgreSQL, MySQL, SQLite, SQL Server or Oracle.
Compared with a spreadsheet, a DBMS gives you:
- Structure that is enforced. Every row in a table has the same columns, and each column has a declared type. You can't put "next Tuesday" in a date column.
- Rules that can't be skipped. You can require that every order refers to a real customer, or that a price is never negative, and the DBMS rejects data that breaks the rule, whoever or whatever sends it.
- Safe sharing. Hundreds of users and programs can read and write at the same time without overwriting each other's work.
- Reliability. Changes are written so that a crash or power cut doesn't leave half an update behind.
- A query language. With SQL (Structured Query Language) you describe what data you want, and the DBMS works out how to get it efficiently, even across millions of rows.
All of these features work best when the design is sound. A DBMS can enforce rules only if the tables are shaped so that the rules can be expressed.
Step 4 of 11Practice · Sort into groups
Which tool is the better fit for each situation?
Tap an item, then tap its group (or drag it there).
Step 5 of 11Learn
The relational model in one picture
Most business databases follow the relational model, proposed by E. F. Codd in 1970. Its idea is simple: store all data in tables (formally called relations).
- A table describes one kind of thing: customers, books, orders.
- Each row (a record, or formally a tuple) is one instance: one customer.
- Each column (an attribute) is one property, with a name and a data type: email, a text value.
- A primary key is a column, or set of columns, whose value uniquely identifies each row.
Tables connect through shared values rather than pointers. An order row stores the customer's id, and to find the customer's name you look up the row in the customer table with that id. This lookup is called a join.
Two properties surprise newcomers. Rows have no built-in order: a table is a set, so if you want results sorted, you must ask for it. And each cell holds a single value: not a list of phone numbers, not a comma-separated set of tags. Those rules feel restrictive at first, but they are what let the DBMS check, index and combine data reliably.
Step 6 of 11Practice · Match the pairs
Match each formal relational term to its everyday equivalent.
Tap an answer, then tap the place where it belongs (or drag it there).
- Relation
- Tuple
- Attribute
- Domain
Step 7 of 11Compare
Relational and NoSQL databases
| Aspect | Relational (SQL) | Document (NoSQL) | Key-value (NoSQL) |
|---|---|---|---|
| Data shape | Tables with fixed columns, linked by keys | Flexible JSON-like documents, often nested | A value looked up by a unique key |
| Strengths | Consistency, rich queries and joins, strong rules | Flexible schema, natural fit for nested objects | Extremely fast simple lookups, easy to scale |
| Typical uses | Orders, banking, inventory, most business apps | Product catalogs, content, user profiles | Caches, sessions, counters |
| Design focus | Normalize, then add indexes | Shape documents around how the app reads them | Choose keys around access patterns |
Step 8 of 11Learn
Three levels of design
Database design usually moves through three levels, from the business view to the machine view.
- Conceptual design. What things does the organization care about, and how are they related? The result is usually an entity-relationship (ER) diagram: boxes for customers, books and orders, lines for "places" and "contains." No technology decisions yet.
- Logical design. Turn the concepts into tables, columns, primary keys and foreign keys, and normalize them to remove redundancy. The result is a schema that would work on any relational DBMS.
- Physical design. Decide how the chosen DBMS will store and speed up the data: exact data types, indexes, partitioning, storage settings.
This course follows the same path. Each level catches different mistakes. Conceptual design catches misunderstandings of the business ("Can an order have several shipping addresses?"). Logical design catches redundancy and anomalies. Physical design catches performance problems. Skipping straight to CREATE TABLE statements is tempting, but changing a table structure after a system is live, with data in it and code depending on it, costs far more than redrawing a box on a diagram.
Step 9 of 11Practice · Put in order
Put the levels of database design in the usual order.
Drag the items, or use the arrow buttons, to put them in order.
- Convert it into normalized tables with keys (logical design)
- Choose data types and indexes for a specific DBMS (physical design)
- Draw an entity-relationship diagram (conceptual design)
- Talk to users and list the things the business tracks
- Create the tables and load data
Step 10 of 11Practice · Diagram
Three levels of design, business view to machine view
Choosing between INTEGER and BIGINT for an id happens at which level?
Tap the shape that answers the question, then press Check.
- Conceptual: ER diagram
Which things matter and how they relate. No tables or data types yet; business people can read it.
- Logical: tables and keys
Tables, columns, primary and foreign keys, normalized. Still independent of a specific product.
- Physical: DDL for one DBMS
Exact data types, indexes and storage settings for PostgreSQL, MySQL or another system.
Step 11 of 11Practice · Choose one
In the relational model, how does an order row connect to the customer who placed it?
Lesson complete!