Database systems · Chapter 6 · Normalization of Database Tables · Beginner guide

Normalization: 1NF, 2NF, 3NF, and transitive dependencies

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

The problem: one table, too many jobs

Here is a table a beginner might build to track employees. Look at it for a moment before reading on. What do you notice?

EMPLOYEE (one table holding everything)
emp_idemp_namedept_iddept_name
101Carolyn Reyes1Accounting
102Marcus Delgado2Engineering
106David Nguyen2Engineering
114Andre Silva3Sales
115Bianca Moreau3Sales
116Kwame Asante3Sales
123Camille Dubois4Human 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

Functional dependency: "if I know A, I know B"

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.

Everyday examples. Read the arrow as "determines."
DependencyTrue?Why
emp_id → emp_nameYesOne employee ID belongs to exactly one person, so it has one name.
dept_id → dept_nameYesDepartment 3 always has the same name, no matter which employee row you look at.
emp_id → dept_idYesEach employee works in one department.
dept_id → emp_idNoDepartment 3 has three employees. Knowing the department does not tell you which one.
emp_name → emp_idNoTwo employees could both be named David Nguyen.
isbn → book_titleYesAn ISBN identifies exactly one edition of one book.
zip_code → cityYes, in our examplesEach ZIP code we use belongs to one city.
(stu_id, class_code) → gradeYesIt takes both the student and the class to pin down one grade.

Key and nonkey columns

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.

The three kinds of dependency that matter

The whole page in one table. Do not worry if the last two are not clear yet.
KindWhat determines the nonkey columnGood or bad?
Full dependencyThe whole primary key, directlyGood. This is what every column should look like.
Partial dependencyOnly part of a composite primary keyBad. Removing these gets you to 2NF.
Transitive dependencyAnother nonkey columnBad. Removing these gets you to 3NF.

Why it matters

The three anomalies

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.

1. Update anomaly: one change, many rows

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:

After an UPDATE that missed one row
emp_idemp_namedept_iddept_name
114Andre Silva3Revenue
115Bianca Moreau3Revenue
116Kwame Asante3Sales

Department 3 now has two names. With thousands of employees, this happens easily, and it is very hard to spot later.

2. Insertion anomaly: cannot add a fact on its own

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.

3. Deletion anomaly: deleting one fact loses another

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

Transitive dependency

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.

A → B   and   B → C   so   A → C (through B)

The employee and department example

Back to our EMPLOYEE table, with emp_id as the primary key. Here are its dependencies:

  1. emp_id → dept_id. Knowing the employee tells you their department number.
  2. dept_id → dept_name. Knowing the department number tells you the department name.
  3. So emp_id → dept_name, but only through dept_id. That is the transitive dependency.
emp_id → dept_id → dept_name
dept_name depends on dept_id, a nonkey column

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."

A quick test for transitive dependencies

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.

The fix: split it into two tables (3NF)

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.

EMPLOYEE
emp_idemp_namedept_id (FK)
101Carolyn Reyes1
102Marcus Delgado2
106David Nguyen2
114Andre Silva3
115Bianca Moreau3
116Kwame Asante3
123Camille Dubois4
DEPARTMENT
dept_iddept_name
1Accounting
2Engineering
3Sales
4Human 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.

All three anomalies are gone

Before and after the split
AnomalyBefore (one table)After (two tables)
UpdateRenaming Sales means changing every Sales employee's rowChange one row: UPDATE DEPARTMENT SET dept_name = 'Revenue' WHERE dept_id = 3;
InsertionCannot add Marketing until someone is hiredJust add it: INSERT INTO DEPARTMENT VALUES (5, 'Marketing');
DeletionDeleting Camille erases Human ResourcesDelete Camille from EMPLOYEE. Department 4 is still in DEPARTMENT.

Nothing was lost

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

More transitive dependency examples

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.

Example 1: students and advisors

stu_idstu_nameadvisor_idadvisor_nameadvisor_office
1001Ana Lopez71R. PatelDBH 210
1002Ben Carter72L. MorenoDBH 118
1003Chloe Wu71R. PatelDBH 210
stu_id → advisor_id → advisor_name, advisor_office

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).

Example 2: orders and customers

order_idorder_datecust_idcust_namecust_city
50012026-09-02C10Maya SinghTurlock
50022026-09-02C11Luis OrtegaModesto
50032026-09-05C10Maya SinghTurlock
order_id → cust_id → cust_name, cust_city

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).

Example 3: products and vendors

prod_codeprod_descriptprod_pricevend_codevend_namevend_phone
P100Claw hammer9.9531001Valley Tools615 555 2273
P101Tape measure7.5031001Valley Tools615 555 2273
P102Drill bit set24.9931002Delta Supply901 555 2253
prod_code → vend_code → vend_name, vend_phone

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.

Example 4: books and publishers

isbntitlepub_idpub_namepub_city
9780000000011Learning SQLP7Northgate PressBoston
9780000000028Data Modeling BasicsP7Northgate PressBoston
9780000000035Python ProjectsP9Valley BooksFresno
isbn → pub_id → pub_name, pub_city

Fix: BOOK (isbn, title, pub_id FK) and PUBLISHER (pub_id, pub_name, pub_city).

Example 5: a transitive dependency with no ID column

The middle column does not have to be called an ID. Here it is a ZIP code.

cust_idcust_namezipcitystate
C10Maya Singh95382TurlockCA
C11Luis Ortega95354ModestoCA
C12Jen Park95382TurlockCA
cust_id → zip → city, state

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.

Example 6: two levels deep

emp_idemp_namedept_iddept_namebldg_codebldg_address
101Carolyn Reyes1AccountingB11 University Cir
114Andre Silva3SalesB2800 Main St
115Bianca Moreau3SalesB2800 Main St
emp_id → dept_id → dept_name, bldg_code
bldg_code → bldg_address

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).

Example 7: no transitive dependency

emp_idemp_namehire_datesalaryemail
101Carolyn Reyes2015-03-12145000[email protected]
102Marcus Delgado2016-06-01102000[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

Partial dependency

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.

The enrollment example

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).

ENROLL, with primary key (stu_id, class_code)
stu_idclass_codegradestu_nameclass_title
1001CIS 4720AAna LopezDatabase Management
1001CIS 2020BAna LopezIntro to Python
1003CIS 4720BChloe WuDatabase 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.

The fix: give each part of the key its own table (2NF)

ENROLL
stu_idclass_codegrade
1001CIS 4720A
1001CIS 2020B
1003CIS 4720B
STUDENT
stu_idstu_name
1001Ana Lopez
1003Chloe Wu
CLASS
class_codeclass_title
CIS 4720Database Management
CIS 2020Intro 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.

More partial dependency examples

Order lines

ORDER_LINE (order_id, prod_code, quantity, order_date, prod_descript)

  • (order_id, prod_code) → quantity: full. How many of this product on this order.
  • order_id → order_date: partial. The date belongs to the whole order.
  • prod_code → prod_descript: partial. The description belongs to the product.

Fix: ORDER_LINE (order_id, prod_code, quantity), ORDERS (order_id, order_date), PRODUCT (prod_code, prod_descript).

Employees on projects

ASSIGNMENT (emp_id, proj_num, hours_worked, emp_name, proj_name)

  • (emp_id, proj_num) → hours_worked: full.
  • emp_id → emp_name: partial.
  • proj_num → proj_name: partial.

Fix: ASSIGNMENT (emp_id, proj_num, hours_worked), EMPLOYEE (emp_id, emp_name), PROJECT (proj_num, proj_name).

Players in games

PLAYER_GAME (player_id, game_id, points_scored, player_name, game_date)

  • (player_id, game_id) → points_scored: full. Points by this player in this game.
  • player_id → player_name: partial.
  • game_id → game_date: partial.

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

1NF, 2NF, and 3NF

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.

First normal form (1NF): one value per cell, and a primary key

A table is in 1NF when:

1NF problem A: a list inside one cell

stu_idstu_namephones
1001Ana Lopez209 555 0101, 209 555 0144
1002Ben Carter209 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).

STUDENT_PHONE
stu_idphone
1001209 555 0101
1001209 555 0144
1002209 555 0177

1NF problem B: repeating columns

stu_idstu_nameclass1class2class3
1001Ana LopezCIS 4720CIS 2020
1003Chloe WuCIS 4720CIS 3680MATH 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).

1NF problem C: blank cells from a report layout

Data copied from a printed report often leaves group values on the first row only:

class_codeclass_titlestu_idstu_name
CIS 4720Database Management1001Ana Lopez
1003Chloe Wu
CIS 2020Intro to Python1001Ana Lopez
1002Ben 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.

Second normal form (2NF): no partial dependencies

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.

Third normal form (3NF): no transitive dependencies

A table is in 3NF when it is in 2NF and it has no transitive dependencies. No nonkey column depends on another nonkey column.

One sentence to remember it all

Every nonkey column must depend on the key (1NF), the whole key (2NF), and nothing but the key (3NF).

The normal forms at a glance
Normal formRuleHow to fix a violation
1NFOne value per cell, no repeating groups, a primary key identifiedFill in blanks, split lists into rows, choose a primary key
2NF1NF, and no partial dependenciesMove each partially dependent column into a table keyed by the part of the key it depends on
3NF2NF, and no transitive dependenciesMove 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

Walkthrough: from a report to 3NF

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.

Step 0: the starting data (0NF)

CLASS ROSTER report, as printed
class_codeclass_titleinstr_idinstr_namestu_idstu_namestu_majorgrade
CIS 4720Database Management501R. Patel1001Ana LopezCISA
1003Chloe WuCISB
CIS 2020Intro to Python502L. Moreno1001Ana LopezCISA
1002Ben CarterMathB
CIS 3680Networking501R. Patel1003Chloe WuCISA

It has a repeating group (several students under each class) and no primary key. This is 0NF, not yet normalized.

Step 1: get to 1NF

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.

ROSTER in 1NF, primary key (class_code, stu_id)
class_codestu_idclass_titleinstr_idinstr_namestu_namestu_majorgrade
CIS 47201001Database Management501R. PatelAna LopezCISA
CIS 47201003Database Management501R. PatelChloe WuCISB
CIS 20201001Intro to Python502L. MorenoAna LopezCISA
CIS 20201002Intro to Python502L. MorenoBen CarterMathB
CIS 36801003Networking501R. PatelChloe WuCISA

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.

Step 2: list every dependency

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.

Dependency diagram for the 1NF ROSTER table Eight boxes in a row: stu_name, stu_major, stu_id, class_code, class_title, instr_id, instr_name, grade. stu_id and class_code are shaded as the primary key. Above, a line from both key boxes points to grade, labeled full dependency. Also above, a line from instr_id points to instr_name, labeled transitive. Below, a line from stu_id points to stu_name and stu_major, labeled partial. Another line below goes from class_code to class_title, instr_id, and instr_name, labeled partial. stu_name stu_major stu_id class_code class_title instr_id instr_name grade full dependency: (stu_id, class_code) determines grade transitive partial (stu_id only) partial (class_code only) shaded boxes are the primary key
The columns are arranged so related ones sit together. The order of columns in a table never matters, so you can rearrange them however makes the diagram easiest to draw.

Step 3: get to 2NF by removing the partial dependencies

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.

STUDENT
stu_idstu_namestu_major
1001Ana LopezCIS
1002Ben CarterMath
1003Chloe WuCIS
ENROLL
class_codestu_idgrade
CIS 47201001A
CIS 47201003B
CIS 20201001A
CIS 20201002B
CIS 36801003A
CLASS (in 2NF, but not yet 3NF)
class_codeclass_titleinstr_idinstr_name
CIS 4720Database Management501R. Patel
CIS 2020Intro to Python502L. Moreno
CIS 3680Networking501R. 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.

Step 4: get to 3NF by removing the transitive dependency

CLASS
class_codeclass_titleinstr_id (FK)
CIS 4720Database Management501
CIS 2020Intro to Python502
CIS 3680Networking501
INSTRUCTOR
instr_idinstr_name
501R. Patel
502L. Moreno

The result: four tables in 3NF

Final design. Underlined columns are primary keys.
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

The final design in SQL

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

Normalization and ER modeling work together

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

Practice

Try each one before opening the answer. Underlined columns are the primary key.

Part A: name the dependency

For each table and dependency, say whether it is full, partial, or transitive.

1. RENTAL (rental_id, rental_date, car_vin, car_model) with car_vin → car_model

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.

2. RENTAL (rental_id, rental_date, car_vin, car_model) with rental_id → rental_date

Full. The key is a single column, and the date belongs directly to the rental. Nothing to fix.

3. TEAM_MEMBER (team_id, player_id, jersey_number, team_name) with team_id → team_name

Partial. team_name depends on only one part of the composite key. Fix: move it to TEAM (team_id, team_name).

4. TEAM_MEMBER (team_id, player_id, jersey_number, team_name) with (team_id, player_id) → jersey_number

Full. A player could wear different numbers on different teams, so you need both parts of the key.

5. PATIENT (patient_id, patient_name, doctor_id, doctor_name, doctor_phone) with doctor_id → doctor_name, doctor_phone

Transitive. Fix: PATIENT (patient_id, patient_name, doctor_id FK) and DOCTOR (doctor_id, doctor_name, doctor_phone).

6. REVIEW (movie_id, user_id, stars, movie_title, user_email) with user_id → user_email

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).

Part B: normalize the table

7. Bring this table to 3NF: CLUB_MEMBER (member_id, member_name, club_id, club_name, club_room)

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).

8. Bring this table to 3NF: CHECKOUT (book_id, card_num, due_date, book_title, author_id, author_name, patron_name)

Assume a book can be checked out by the same patron only once, so the composite key works. Dependencies:

  • (book_id, card_num) → due_date: full
  • book_id → book_title, author_id, author_name: partial
  • card_num → patron_name: partial
  • author_id → author_name: transitive

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.

9. What is wrong with this table, and which normal form does it break? PIZZA_ORDER (order_id, cust_name, toppings) with a row of 5001, Maya Singh, "pepperoni, olives, onion"

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.

10. For the EMPLOYEE table at the top of this page, name one example of each anomaly.
  • Update: renaming Sales means changing three rows, and missing one leaves two names for department 3.
  • Insertion: a new department with no employees cannot be added, because emp_id cannot be NULL.
  • Deletion: deleting Camille Dubois removes the only record of Human Resources.

Quick check

If you remember only these

  • Normalization removes redundancy by splitting a table that holds facts about more than one thing.
  • Redundancy causes update, insertion, and deletion anomalies.
  • A → B means: know A, and you know exactly one B.
  • A partial dependency is a nonkey column that depends on part of a composite key. Removing them gives 2NF.
  • A transitive dependency is a nonkey column that depends on another nonkey column (A → B → C). Removing them gives 3NF.
  • To find transitive dependencies, cover up the key and ask whether one remaining column tells you another.
  • The fix is always the same: move the dependent columns into a new table keyed by their determinant, and leave the determinant behind as a foreign key.
  • The key, the whole key, and nothing but the key: 1NF, 2NF, 3NF.
  • Joins put the data back together, so nothing is lost by normalizing.