Database systems · Chapter 6 · Normalization of Database Tables · Beginner guide
Normalization is a step by step way to check a table design and split up any table that is trying to hold facts about more than one thing. A normalized design stores each fact once, so it cannot contradict itself. This page goes slowly, with lots of small tables, and every new idea comes with several examples.
Course Objective 3: Design a database at the conceptual level using ER modeling, normalization, and semantic modeling. This page covers the normalization part. For ER modeling, see Crow's Foot notation and the cardinality examples.
Start here
Here is a table a beginner might build to track employees. Look at it for a moment before reading on. What do you notice?
| emp_id | emp_name | dept_id | dept_name |
|---|---|---|---|
| 101 | Carolyn Reyes | 1 | Accounting |
| 102 | Marcus Delgado | 2 | Engineering |
| 106 | David Nguyen | 2 | Engineering |
| 114 | Andre Silva | 3 | Sales |
| 115 | Bianca Moreau | 3 | Sales |
| 116 | Kwame Asante | 3 | Sales |
| 123 | Camille Dubois | 4 | Human Resources |
The fact "department 3 is called Sales" is written three times. The fact "department 2 is called Engineering" is written twice. Storing the same fact over and over is called data redundancy, and it is the thing normalization removes.
Redundancy is not just wasted space. Every copy is a chance for the copies to disagree. If one row says department 3 is "Sales" and another says it is "Revenue," which one is right? The database cannot tell you.
The cause is that this table is doing two jobs at once. It describes employees, and it also describes departments. Normalization is the process of finding those hidden second jobs and giving each one its own table.
Refresher from Chapter 3
Every rule in normalization is stated in terms of functional dependencies, so it is worth getting comfortable with them first.
A determines B, written A → B, means: if you know a value of A, there is exactly one matching value of B. A is the determinant, and B is the dependent. (The Chapter 3 review has the formal definition.)
A good way to test it: ask "if two rows have the same A, must they have the same B?" If the answer is always yes, then A → B.
| Dependency | True? | Why |
|---|---|---|
| emp_id → emp_name | Yes | One employee ID belongs to exactly one person, so it has one name. |
| dept_id → dept_name | Yes | Department 3 always has the same name, no matter which employee row you look at. |
| emp_id → dept_id | Yes | Each employee works in one department. |
| dept_id → emp_id | No | Department 3 has three employees. Knowing the department does not tell you which one. |
| emp_name → emp_id | No | Two employees could both be named David Nguyen. |
| isbn → book_title | Yes | An ISBN identifies exactly one edition of one book. |
| zip_code → city | Yes, in our examples | Each ZIP code we use belongs to one city. |
| (stu_id, class_code) → grade | Yes | It takes both the student and the class to pin down one grade. |
Two more words you will see constantly:
In the EMPLOYEE table above, emp_id is the key attribute. emp_name, dept_id, and dept_name are nonkey attributes.
| Kind | What determines the nonkey column | Good or bad? |
|---|---|---|
| Full dependency | The whole primary key, directly | Good. This is what every column should look like. |
| Partial dependency | Only part of a composite primary key | Bad. Removing these gets you to 2NF. |
| Transitive dependency | Another nonkey column | Bad. Removing these gets you to 3NF. |
Why it matters
An anomaly is something that goes wrong, or cannot be done, because of how a table is designed. A table with redundancy suffers from three of them. We will use the EMPLOYEE table from the top of the page.
The company renames the Sales department to "Revenue." Because the name is stored in every Sales employee's row, you must change three rows. Miss one, and the data contradicts itself:
| emp_id | emp_name | dept_id | dept_name |
|---|---|---|---|
| 114 | Andre Silva | 3 | Revenue |
| 115 | Bianca Moreau | 3 | Revenue |
| 116 | Kwame Asante | 3 | Sales |
Department 3 now has two names. With thousands of employees, this happens easily, and it is very hard to spot later.
The company creates a new Marketing department, number 5, but has not hired anyone for it yet. Where do we record it? Every row in EMPLOYEE needs an emp_id, because that is the primary key, and a primary key cannot be NULL.
INSERT INTO EMPLOYEE (emp_id, emp_name, dept_id, dept_name)
VALUES (NULL, NULL, 5, 'Marketing');
-- rejected: the primary key emp_id cannot be NULL
We cannot record the department until we hire someone. The only way around it is to invent a fake employee, which is worse.
Camille Dubois, the only person in Human Resources, leaves the company. We delete her row:
DELETE FROM EMPLOYEE WHERE emp_id = 123;
That was the only row that mentioned department 4. The database no longer knows that a Human Resources department exists, or what its number is. We meant to delete an employee, and we deleted a department too.
The pattern behind all three: two different kinds of fact (employee facts and department facts) are locked together in the same row. You cannot change, add, or remove one without touching the other. Every fix on this page works the same way: split the table so each kind of fact gets its own row in its own table.
The main idea
A transitive dependency is when a nonkey column depends on another nonkey column, instead of depending directly on the primary key.
The word "transitive" comes from a rule you may know from math: if A determines B, and B determines C, then A determines C, but only indirectly, by passing through B.
Back to our EMPLOYEE table, with emp_id as the primary key. Here are its dependencies:
dept_id. That is the transitive dependency.Compare that with emp_name. An employee's name belongs to the employee directly. Nothing else in the row decides it. That is a healthy, direct dependency on the key.
The department name is different. It is really a fact about the department, not about the employee. It only ended up in this table because we were looking it up through the employee's department number. That is exactly why it repeats: every employee in department 3 drags along its own copy of "Sales."
Cover up the primary key with your hand. Now look only at the nonkey columns that are left. Can any one of them tell you the value of another? If yes, you have found a transitive dependency.
In EMPLOYEE: hide emp_id. Does dept_id tell you dept_name? Yes. Transitive dependency found.
Move the department facts into their own table, with dept_id as its primary key. Leave dept_id behind in EMPLOYEE as a foreign key, so we can still find each employee's department.
| emp_id | emp_name | dept_id (FK) |
|---|---|---|
| 101 | Carolyn Reyes | 1 |
| 102 | Marcus Delgado | 2 |
| 106 | David Nguyen | 2 |
| 114 | Andre Silva | 3 |
| 115 | Bianca Moreau | 3 |
| 116 | Kwame Asante | 3 |
| 123 | Camille Dubois | 4 |
| dept_id | dept_name |
|---|---|
| 1 | Accounting |
| 2 | Engineering |
| 3 | Sales |
| 4 | Human Resources |
Now every nonkey column depends directly on its own table's primary key: emp_name and dept_id on emp_id, and dept_name on dept_id. "Sales" is stored exactly once.
| Anomaly | Before (one table) | After (two tables) |
|---|---|---|
| Update | Renaming Sales means changing every Sales employee's row | Change one row: UPDATE DEPARTMENT SET dept_name = 'Revenue' WHERE dept_id = 3; |
| Insertion | Cannot add Marketing until someone is hired | Just add it: INSERT INTO DEPARTMENT VALUES (5, 'Marketing'); |
| Deletion | Deleting Camille erases Human Resources | Delete Camille from EMPLOYEE. Department 4 is still in DEPARTMENT. |
A common worry: "But now the department name is not next to the employee." A JOIN puts it right back whenever you need it:
SELECT E.emp_id, E.emp_name, E.dept_id, D.dept_name
FROM EMPLOYEE E
JOIN DEPARTMENT D ON E.dept_id = D.dept_id
ORDER BY E.emp_id;
-- returns exactly the original one table version, built fresh each time
That is the deal normalization offers: store each fact once, and use joins to combine them when you read. See the JOIN examples page for more practice with this.
Practice spotting them
The pattern is always the same: a column that is really an ID for some other thing, followed by facts about that other thing. Once you see it a few times, you will spot it right away.
| stu_id | stu_name | advisor_id | advisor_name | advisor_office |
|---|---|---|---|---|
| 1001 | Ana Lopez | 71 | R. Patel | DBH 210 |
| 1002 | Ben Carter | 72 | L. Moreno | DBH 118 |
| 1003 | Chloe Wu | 71 | R. Patel | DBH 210 |
The clue: R. Patel's name and office repeat for every advisee. If R. Patel moves offices, every one of those rows must change.
Fix: STUDENT (stu_id, stu_name, advisor_id FK) and ADVISOR (advisor_id, advisor_name, advisor_office).
| order_id | order_date | cust_id | cust_name | cust_city |
|---|---|---|---|---|
| 5001 | 2026-09-02 | C10 | Maya Singh | Turlock |
| 5002 | 2026-09-02 | C11 | Luis Ortega | Modesto |
| 5003 | 2026-09-05 | C10 | Maya Singh | Turlock |
The clue: the order date belongs to the order, but the customer's name and city belong to the customer. Maya's details repeat on every order she places.
Fix: ORDERS (order_id, order_date, cust_id FK) and CUSTOMER (cust_id, cust_name, cust_city).
| prod_code | prod_descript | prod_price | vend_code | vend_name | vend_phone |
|---|---|---|---|---|---|
| P100 | Claw hammer | 9.95 | 31001 | Valley Tools | 615 555 2273 |
| P101 | Tape measure | 7.50 | 31001 | Valley Tools | 615 555 2273 |
| P102 | Drill bit set | 24.99 | 31002 | Delta Supply | 901 555 2253 |
Fix: PRODUCT (prod_code, prod_descript, prod_price, vend_code FK) and VENDOR (vend_code, vend_name, vend_phone). This is the same PRODUCT and VENDOR pair used in the Chapter 4 and 5 reviews.
| isbn | title | pub_id | pub_name | pub_city |
|---|---|---|---|---|
| 9780000000011 | Learning SQL | P7 | Northgate Press | Boston |
| 9780000000028 | Data Modeling Basics | P7 | Northgate Press | Boston |
| 9780000000035 | Python Projects | P9 | Valley Books | Fresno |
Fix: BOOK (isbn, title, pub_id FK) and PUBLISHER (pub_id, pub_name, pub_city).
The middle column does not have to be called an ID. Here it is a ZIP code.
| cust_id | cust_name | zip | city | state |
|---|---|---|---|---|
| C10 | Maya Singh | 95382 | Turlock | CA |
| C11 | Luis Ortega | 95354 | Modesto | CA |
| C12 | Jen Park | 95382 | Turlock | CA |
Fix: CUSTOMER (cust_id, cust_name, zip FK) and ZIP_CODE (zip, city, state).
A real world note: many companies leave city and state in the customer table anyway, because addresses are almost always read together and ZIP codes occasionally cross city lines. Choosing to keep a known redundancy on purpose is called denormalization. It is fine as a deliberate decision, but you should always be able to say where the transitive dependency is and why you kept it.
| emp_id | emp_name | dept_id | dept_name | bldg_code | bldg_address |
|---|---|---|---|---|---|
| 101 | Carolyn Reyes | 1 | Accounting | B1 | 1 University Cir |
| 114 | Andre Silva | 3 | Sales | B2 | 800 Main St |
| 115 | Bianca Moreau | 3 | Sales | B2 | 800 Main St |
Each department is in one building, and each building has one address. Split twice: EMPLOYEE (emp_id, emp_name, dept_id FK), DEPARTMENT (dept_id, dept_name, bldg_code FK), and BUILDING (bldg_code, bldg_address).
| emp_id | emp_name | hire_date | salary | |
|---|---|---|---|---|
| 101 | Carolyn Reyes | 2015-03-12 | 145000 | [email protected] |
| 102 | Marcus Delgado | 2016-06-01 | 102000 | [email protected] |
Cover up emp_id. Does the hire date tell you the salary? No. Does the salary tell you the name? No. Every column is a fact about the employee and nothing else, so this table is already in 3NF. Not every table needs splitting.
The other problem
A partial dependency is when a nonkey column depends on only part of a composite primary key. It can only happen when the primary key has two or more columns.
A table of which students are in which classes needs both columns to identify a row, so its primary key is (stu_id, class_code).
| stu_id | class_code | grade | stu_name | class_title |
|---|---|---|---|---|
| 1001 | CIS 4720 | A | Ana Lopez | Database Management |
| 1001 | CIS 2020 | B | Ana Lopez | Intro to Python |
| 1003 | CIS 4720 | B | Chloe Wu | Database Management |
You can see the redundancy: "Ana Lopez" repeats for every class Ana takes, and "Database Management" repeats for every student in it.
A quick test for partial dependencies: cover up one column of the composite key. Can the column that is left still tell you some nonkey column on its own? If yes, that column is partially dependent.
| stu_id | class_code | grade |
|---|---|---|
| 1001 | CIS 4720 | A |
| 1001 | CIS 2020 | B |
| 1003 | CIS 4720 | B |
| stu_id | stu_name |
|---|---|
| 1001 | Ana Lopez |
| 1003 | Chloe Wu |
| class_code | class_title |
|---|---|
| CIS 4720 | Database Management |
| CIS 2020 | Intro to Python |
ENROLL keeps only what needs the whole key: the grade. In ENROLL, stu_id and class_code are each a foreign key back to STUDENT and CLASS.
ORDER_LINE (order_id, prod_code, quantity, order_date, prod_descript)
Fix: ORDER_LINE (order_id, prod_code, quantity), ORDERS (order_id, order_date), PRODUCT (prod_code, prod_descript).
ASSIGNMENT (emp_id, proj_num, hours_worked, emp_name, proj_name)
Fix: ASSIGNMENT (emp_id, proj_num, hours_worked), EMPLOYEE (emp_id, emp_name), PROJECT (proj_num, proj_name).
PLAYER_GAME (player_id, game_id, points_scored, player_name, game_date)
Fix: PLAYER_GAME (player_id, game_id, points_scored), PLAYER (player_id, player_name), GAME (game_id, game_date).
Partial versus transitive, side by side. Both are cases of a column depending on the wrong thing. A partial dependency depends on a piece of the key. A transitive dependency depends on something that is not in the key at all. If your table has a single column primary key, it cannot have a partial dependency, so you only need to look for transitive ones.
The normal forms
Each normal form is a checklist. A table must pass the earlier one before it can move on to the next, like levels in a game.
A table is in 1NF when:
| stu_id | stu_name | phones |
|---|---|---|
| 1001 | Ana Lopez | 209 555 0101, 209 555 0144 |
| 1002 | Ben Carter | 209 555 0177 |
You cannot easily search for one phone number, count them, or delete just one. Fix: one row per phone in its own table, STUDENT_PHONE (stu_id, phone).
| stu_id | phone |
|---|---|
| 1001 | 209 555 0101 |
| 1001 | 209 555 0144 |
| 1002 | 209 555 0177 |
| stu_id | stu_name | class1 | class2 | class3 |
|---|---|---|---|---|
| 1001 | Ana Lopez | CIS 4720 | CIS 2020 | |
| 1003 | Chloe Wu | CIS 4720 | CIS 3680 | MATH 1600 |
What happens when a student takes four classes? You would have to add a column to the table. And to find everyone in CIS 4720, you must search three columns. Fix: one row per student per class, ENROLL (stu_id, class_code).
Data copied from a printed report often leaves group values on the first row only:
| class_code | class_title | stu_id | stu_name |
|---|---|---|---|
| CIS 4720 | Database Management | 1001 | Ana Lopez |
| 1003 | Chloe Wu | ||
| CIS 2020 | Intro to Python | 1001 | Ana Lopez |
| 1002 | Ben Carter |
A person reads the blank as "same as above," but a database cannot. The group of students under each class is a repeating group. Fix: fill in every blank so each row stands on its own, then pick a primary key, here (class_code, stu_id). The walkthrough below does exactly this.
A table is in 2NF when it is in 1NF and it has no partial dependencies. Every nonkey column depends on the whole primary key.
Shortcut: a 1NF table whose primary key is a single column is automatically in 2NF, because there is no "part" of the key to depend on.
A table is in 3NF when it is in 2NF and it has no transitive dependencies. No nonkey column depends on another nonkey column.
Every nonkey column must depend on the key (1NF), the whole key (2NF), and nothing but the key (3NF).
| Normal form | Rule | How to fix a violation |
|---|---|---|
| 1NF | One value per cell, no repeating groups, a primary key identified | Fill in blanks, split lists into rows, choose a primary key |
| 2NF | 1NF, and no partial dependencies | Move each partially dependent column into a table keyed by the part of the key it depends on |
| 3NF | 2NF, and no transitive dependencies | Move each transitively dependent column into a table keyed by the nonkey column it depends on, and leave that column behind as a foreign key |
There are higher normal forms (Boyce Codd normal form, 4NF) that handle rarer situations. For most business databases, reaching 3NF is the goal, and it is the level this course expects.
Putting it together
Now we take one messy table all the way through. The department office gives us this class roster report and asks us to design a database for it.
| class_code | class_title | instr_id | instr_name | stu_id | stu_name | stu_major | grade |
|---|---|---|---|---|---|---|---|
| CIS 4720 | Database Management | 501 | R. Patel | 1001 | Ana Lopez | CIS | A |
| 1003 | Chloe Wu | CIS | B | ||||
| CIS 2020 | Intro to Python | 502 | L. Moreno | 1001 | Ana Lopez | CIS | A |
| 1002 | Ben Carter | Math | B | ||||
| CIS 3680 | Networking | 501 | R. Patel | 1003 | Chloe Wu | CIS | A |
It has a repeating group (several students under each class) and no primary key. This is 0NF, not yet normalized.
Fill in the blanks so every row is complete, then find a primary key. One class has many students, and one student takes many classes, so neither column alone is unique. Together, (class_code, stu_id) identifies exactly one row.
| class_code | stu_id | class_title | instr_id | instr_name | stu_name | stu_major | grade |
|---|---|---|---|---|---|---|---|
| CIS 4720 | 1001 | Database Management | 501 | R. Patel | Ana Lopez | CIS | A |
| CIS 4720 | 1003 | Database Management | 501 | R. Patel | Chloe Wu | CIS | B |
| CIS 2020 | 1001 | Intro to Python | 502 | L. Moreno | Ana Lopez | CIS | A |
| CIS 2020 | 1002 | Intro to Python | 502 | L. Moreno | Ben Carter | Math | B |
| CIS 3680 | 1003 | Networking | 501 | R. Patel | Chloe Wu | CIS | A |
The green cells were filled in. Notice how much now repeats: "R. Patel" three times, "Ana Lopez" twice, "Database Management" twice. Those repeats are the clues for the next two steps.
A dependency diagram draws them all at once. The primary key is shaded. Arrows above the boxes are fine; arrows below are the problems we must remove.
Each part of the key that determines something gets its own table, and takes its dependents with it. The original key stays behind with the columns that need all of it.
| stu_id | stu_name | stu_major |
|---|---|---|
| 1001 | Ana Lopez | CIS |
| 1002 | Ben Carter | Math |
| 1003 | Chloe Wu | CIS |
| class_code | stu_id | grade |
|---|---|---|
| CIS 4720 | 1001 | A |
| CIS 4720 | 1003 | B |
| CIS 2020 | 1001 | A |
| CIS 2020 | 1002 | B |
| CIS 3680 | 1003 | A |
| class_code | class_title | instr_id | instr_name |
|---|---|---|---|
| CIS 4720 | Database Management | 501 | R. Patel |
| CIS 2020 | Intro to Python | 502 | L. Moreno |
| CIS 3680 | Networking | 501 | R. Patel |
Ana Lopez is now stored once, and so is each class title. STUDENT and ENROLL are already in 3NF. But CLASS still repeats "R. Patel" for every class Patel teaches. Cover up class_code: instr_id still tells you instr_name. That is the transitive dependency.
| class_code | class_title | instr_id (FK) |
|---|---|---|
| CIS 4720 | Database Management | 501 |
| CIS 2020 | Intro to Python | 502 |
| CIS 3680 | Networking | 501 |
| instr_id | instr_name |
|---|---|
| 501 | R. Patel |
| 502 | L. Moreno |
| STUDENT | (stu_id, stu_name, stu_major) |
| INSTRUCTOR | (instr_id, instr_name) |
| CLASS | (class_code, class_title, instr_id) with instr_id a foreign key to INSTRUCTOR |
| ENROLL | (class_code, stu_id, grade) with each key column a foreign key to CLASS and STUDENT |
Check each table with the sentence from earlier. Does every nonkey column depend on the key, the whole key, and nothing but the key? Yes, in all four.
From design to database
Each table in the design becomes a CREATE TABLE. The foreign keys are what tie the pieces back together.
CREATE TABLE STUDENT (
stu_id INT PRIMARY KEY,
stu_name VARCHAR(40) NOT NULL,
stu_major VARCHAR(20)
);
CREATE TABLE INSTRUCTOR (
instr_id INT PRIMARY KEY,
instr_name VARCHAR(40) NOT NULL
);
CREATE TABLE CLASS (
class_code VARCHAR(10) PRIMARY KEY,
class_title VARCHAR(60) NOT NULL,
instr_id INT,
FOREIGN KEY (instr_id) REFERENCES INSTRUCTOR (instr_id)
);
CREATE TABLE ENROLL (
class_code VARCHAR(10),
stu_id INT,
grade CHAR(2),
PRIMARY KEY (class_code, stu_id),
FOREIGN KEY (class_code) REFERENCES CLASS (class_code),
FOREIGN KEY (stu_id) REFERENCES STUDENT (stu_id)
);
And this query rebuilds the original roster report from the four tables, showing that splitting them lost nothing:
SELECT C.class_code, C.class_title, I.instr_id, I.instr_name,
S.stu_id, S.stu_name, S.stu_major, E.grade
FROM ENROLL E
JOIN STUDENT S ON E.stu_id = S.stu_id
JOIN CLASS C ON E.class_code = C.class_code
JOIN INSTRUCTOR I ON C.instr_id = I.instr_id
ORDER BY C.class_code, S.stu_id;
Why bother? Try each anomaly on the new design. R. Patel changes names: one UPDATE on INSTRUCTOR. A new class with no students yet: one INSERT into CLASS. Ben Carter drops CIS 2020: delete one ENROLL row, and Ben, the class, and the instructor are all still there.
Course Objective 3
ER modeling and normalization come at the same problem from opposite directions, and good designers use both.
Look at what the walkthrough produced. STUDENT, INSTRUCTOR, and CLASS are entities. ENROLL is the bridge (associative) entity that resolves the many to many relationship between STUDENT and CLASS. INSTRUCTOR to CLASS is a one to many relationship, carried by the foreign key instr_id. Normalizing the roster report led to the same design you would draw as an ERD.
In practice: draw the ERD first, then normalize each table it produces to check that nothing slipped through. Each time you find a transitive dependency, you have usually found an entity you forgot to draw.
For the ER side of this objective, see Crow's Foot notation, the cardinality examples, and the customer and invoice ERD.
Your turn
Try each one before opening the answer. Underlined columns are the primary key.
For each table and dependency, say whether it is full, partial, or transitive.
Transitive. car_vin is a nonkey column, and it determines car_model. Chain: rental_id → car_vin → car_model. Fix: move car_model into a CAR (car_vin, car_model) table.
Full. The key is a single column, and the date belongs directly to the rental. Nothing to fix.
Partial. team_name depends on only one part of the composite key. Fix: move it to TEAM (team_id, team_name).
Full. A player could wear different numbers on different teams, so you need both parts of the key.
Transitive. Fix: PATIENT (patient_id, patient_name, doctor_id FK) and DOCTOR (doctor_id, doctor_name, doctor_phone).
Partial. And movie_id → movie_title is a second partial dependency. Fix: REVIEW (movie_id, user_id, stars), MOVIE (movie_id, movie_title), USER (user_id, user_email).
The key is one column, so it is already in 2NF. Cover up member_id: club_id determines club_name and club_room, which is a transitive dependency.
3NF: MEMBER (member_id, member_name, club_id FK) and CLUB (club_id, club_name, club_room).
Assume a book can be checked out by the same patron only once, so the composite key works. Dependencies:
2NF: CHECKOUT (book_id, card_num, due_date), BOOK (book_id, book_title, author_id, author_name), PATRON (card_num, patron_name).
3NF: split BOOK into BOOK (book_id, book_title, author_id FK) and AUTHOR (author_id, author_name). Four tables in total, the same shape as the class roster walkthrough.
It breaks 1NF: the toppings cell holds a list. Fix: ORDER_TOPPING (order_id, topping), one row per topping. Then check the rest. If the table also stored a customer ID with the name, that would be a transitive dependency to remove for 3NF.