To normalize the given books table through First Normal Form (1NF), Second Normal Form (2NF), and Third Normal Form (3NF), follow these steps:
Initial Table Structure
| title_id | title_name | retail_price | location_1 | location_2 | location_3 |
|---|
| 102 | 200 Years of German Humor | 19.95 | New York | San Francisco | |
| 103 | Ask Your System Administrator | 39.95 | Chicago | | |
| 104 | But I Did It Unconsciously | 12.99 | Miami | London | New York |
1. First Normal Form (1NF)
Objective: Eliminate repeating groups to ensure each field contains only atomic (indivisible) values.
Action: Convert the multiple location columns into separate rows so that each row represents a single location for a book.
1NF Table Structure:
| title_id | title_name | retail_price | location |
|---|
| 102 | 200 Years of German Humor | 19.95 | New York |
| 102 | 200 Years of German Humor | 19.95 | San Francisco |
| 103 | Ask Your System Administrator | 39.95 | Chicago |
| 104 | But I Did It Unconsciously | 12.99 | Miami |
| 104 | But I Did It Unconsciously | 12.99 | London |
| 104 | But I Did It Unconsciously | 12.99 | New York |
2. Second Normal Form (2NF)
Objective: Remove partial dependencies, ensuring that non-key attributes are fully functionally dependent on the entire primary key.
Action:
Books Table:
| title_id | title_name | retail_price |
|---|
| 102 | 200 Years of German Humor | 19.95 |
| 103 | Ask Your System Administrator | 39.95 |
| 104 | But I Did It Unconsciously | 12.99 |
Locations Table:
| title_id | location |
|---|
| 102 | New York |
| 102 | San Francisco |
| 103 | Chicago |
| 104 | Miami |
| 104 | London |
| 104 | New York |
Explanation:
- The Books table has
title_id as the primary key.
- The Locations table uses a composite key
(title_id, location) to uniquely identify each location entry.
3. Third Normal Form (3NF)
Objective: Eliminate transitive dependencies, ensuring that non-key attributes do not depend on other non-key attributes.
Action:
- Assess Tables for Transitive Dependencies:
-
Books Table:
title_id → title_name, retail_price
- No transitive dependencies exist as
title_name and retail_price depend solely on title_id.
-
Locations Table:
- Contains only
title_id and location with no additional attributes, so no transitive dependencies exist.
Result: Both the Books and Locations tables are already in 3NF.
Final Normalized Structure
Books Table (3NF):
| title_id | title_name | retail_price |
|---|
| 102 | 200 Years of German Humor | 19.95 |
| 103 | Ask Your System Administrator | 39.95 |
| 104 | But I Did It Unconsciously | 12.99 |
Locations Table (3NF):
| title_id | location |
|---|
| 102 | New York |
| 102 | San Francisco |
| 103 | Chicago |
| 104 | Miami |
| 104 | London |
| 104 | New York |
Summary of Normalization Steps
- 1NF: Flattened the table by creating separate rows for each location.
- 2NF: Split the table into
Books and Locations tables to remove partial dependencies.
- 3NF: Ensured no transitive dependencies exist, maintaining the structure achieved in 2NF.
This normalization process ensures data integrity, reduces redundancy, and optimizes the database structure for efficient querying and maintenance.