Bird
Raised Fist0
DBMS Theoryknowledge~6 mins

Third Normal Form (3NF) in DBMS Theory - Full Explanation

Choose your learning style10 modes available
Introduction
Imagine you have a messy spreadsheet where some information repeats and causes confusion when you update it. Third Normal Form helps organize data in databases so that each piece of information is stored only once, making updates easier and errors less likely.
Explanation
Purpose of 3NF
Third Normal Form aims to reduce duplication and dependency in database tables. It ensures that every non-key column depends only on the primary key, not on other non-key columns. This helps keep data consistent and easy to maintain.
3NF removes indirect dependencies to prevent data anomalies.
Requirements for 3NF
A table is in 3NF if it is already in Second Normal Form (2NF) and no non-key column depends on another non-key column. This means no transitive dependencies exist, where one non-key column relies on another non-key column instead of the primary key.
3NF requires eliminating transitive dependencies between non-key columns.
Transitive Dependency Explained
A transitive dependency happens when a column depends on another column that is not the primary key. For example, if 'City' depends on 'Zip Code', and 'Zip Code' depends on the primary key, then 'City' indirectly depends on the primary key through 'Zip Code'. 3NF removes such indirect links.
Transitive dependencies cause indirect links that 3NF removes.
Benefits of 3NF
By organizing data into 3NF, databases avoid redundant data and reduce the chance of inconsistent updates. This makes the database more reliable and easier to update without errors. It also improves storage efficiency by not repeating the same data.
3NF improves data consistency and reduces redundancy.
Real World Analogy

Think of a library where books are organized by author and title. If the library kept repeating the author's address with every book, it would be messy and hard to update. Instead, the library keeps author details separate and links books to authors, so updating an address happens in one place.

Purpose of 3NF → Keeping author details separate to avoid repeating the same address for every book
Requirements for 3NF → Ensuring each book record only links to the author, not repeating author details inside the book record
Transitive Dependency Explained → Avoiding storing author address inside the book record because it depends on the author, not the book
Benefits of 3NF → Easier updates when an author's address changes, done once without errors
Diagram
Diagram
┌───────────────┐       ┌───────────────┐
│   Book Table  │       │  Author Table │
├───────────────┤       ├───────────────┤
│ BookID (PK)   │──────▶│ AuthorID (PK) │
│ Title         │       │ Name          │
│ AuthorID (FK) │       │ Address       │
└───────────────┘       └───────────────┘
Diagram showing how book records link to author records separately to avoid repeating author details.
Key Facts
Third Normal Form (3NF) → A database table is in 3NF if it has no transitive dependencies and every non-key column depends only on the primary key.
Transitive Dependency → A situation where a non-key column depends on another non-key column instead of directly on the primary key.
Primary Key → A unique identifier for each record in a database table.
Second Normal Form (2NF) → A table is in 2NF if it is in 1NF and all non-key columns depend on the whole primary key.
Data Redundancy → Unnecessary repetition of data in a database.
Common Confusions
Believing 3NF means no repeated data at all.
Believing 3NF means no repeated data at all. 3NF reduces unnecessary repetition but some data may still repeat if it depends directly on the primary key.
Thinking 3NF applies only to single-column primary keys.
Thinking 3NF applies only to single-column primary keys. 3NF applies to tables with single or composite primary keys as long as transitive dependencies are removed.
Confusing 3NF with 2NF and their requirements.
Confusing 3NF with 2NF and their requirements. 2NF removes partial dependencies on part of a composite key, while 3NF removes transitive dependencies between non-key columns.
Summary
Third Normal Form organizes data so that every non-key column depends only on the primary key, removing indirect dependencies.
It eliminates transitive dependencies to reduce data duplication and improve consistency.
3NF makes databases easier to maintain by separating related data into linked tables.

Practice

(1/5)
1. What is the main goal of the Third Normal Form (3NF) in database design?
easy
A. To ensure no non-key column depends on another non-key column
B. To remove all duplicate rows from a table
C. To combine multiple tables into one
D. To allow NULL values in all columns

Solution

  1. Step 1: Understand 3NF definition

    3NF requires that every non-key column depends only on the primary key, not on other non-key columns.
  2. Step 2: Compare options with 3NF goal

    Only To ensure no non-key column depends on another non-key column correctly states this goal. Other options describe different concepts.
  3. Final Answer:

    To ensure no non-key column depends on another non-key column -> Option A
  4. Quick Check:

    3NF = No transitive dependency [OK]
Hint: 3NF removes transitive dependencies between non-key columns [OK]
Common Mistakes:
  • Confusing 3NF with removing duplicates
  • Thinking 3NF merges tables
  • Believing 3NF allows NULLs everywhere
2. Which of the following functional dependencies violates the Third Normal Form (3NF)?
easy
A. PrimaryKey -> NonKeyColumn
B. NonKeyColumn1 -> NonKeyColumn2
C. PrimaryKey -> CompositeKey
D. PrimaryKey -> ForeignKey

Solution

  1. Step 1: Identify 3NF violation

    3NF disallows non-key columns determining other non-key columns (transitive dependency).
  2. Step 2: Analyze each dependency

    NonKeyColumn1 -> NonKeyColumn2 shows a non-key column determining another non-key column, violating 3NF.
  3. Final Answer:

    NonKeyColumn1 -> NonKeyColumn2 -> Option B
  4. Quick Check:

    Transitive dependency = 3NF violation [OK]
Hint: Watch for non-key to non-key dependencies breaking 3NF [OK]
Common Mistakes:
  • Assuming all dependencies from primary key violate 3NF
  • Confusing foreign keys with functional dependencies
  • Ignoring transitive dependencies
3. Consider a table with columns StudentID (primary key), AdvisorName, and AdvisorOffice. If AdvisorName determines AdvisorOffice, which of the following is true about this table regarding 3NF?
medium
A. The table is in 3NF because StudentID is the primary key
B. The table violates 3NF because AdvisorOffice depends on StudentID
C. The table is in 3NF because AdvisorOffice depends on AdvisorName
D. The table violates 3NF due to transitive dependency

Solution

  1. Step 1: Identify dependencies

    StudentID -> AdvisorName and AdvisorName -> AdvisorOffice shows a transitive dependency.
  2. Step 2: Check 3NF rules

    3NF disallows non-key columns (AdvisorName) determining other non-key columns (AdvisorOffice).
  3. Final Answer:

    The table violates 3NF due to transitive dependency -> Option D
  4. Quick Check:

    Transitive dependency breaks 3NF [OK]
Hint: Check if non-key columns determine others to spot 3NF violation [OK]
Common Mistakes:
  • Thinking primary key alone ensures 3NF
  • Ignoring transitive dependencies
  • Confusing direct and transitive dependencies
4. A table has columns OrderID (primary key), CustomerName, and CustomerCity. The dependency CustomerName -> CustomerCity exists. What is the problem with this table in terms of 3NF, and how can it be fixed?
medium
A. Violates 3NF; fix by splitting into two tables separating customer info
B. No problem; table is already in 3NF
C. Violates 3NF; fix by adding CustomerCity to primary key
D. No problem; just rename columns

Solution

  1. Step 1: Identify 3NF violation

    CustomerName -> CustomerCity is a transitive dependency violating 3NF.
  2. Step 2: Fix violation by normalization

    Split table into Orders and Customers tables to separate customer details.
  3. Final Answer:

    Violates 3NF; fix by splitting into two tables separating customer info -> Option A
  4. Quick Check:

    Split tables to remove transitive dependencies [OK]
Hint: Split tables to remove non-key to non-key dependencies [OK]
Common Mistakes:
  • Adding columns to primary key incorrectly
  • Ignoring transitive dependencies
  • Thinking renaming fixes normalization
5. You have a table with columns EmployeeID (primary key), DepartmentID, DepartmentName, and ManagerID. DepartmentID determines DepartmentName and ManagerID. How should you redesign the table to achieve Third Normal Form (3NF)?
hard
A. Keep all columns in one table because EmployeeID is primary key
B. Add DepartmentName and ManagerID to EmployeeID primary key
C. Create two tables: one for Employees and one for Departments with DepartmentID as key
D. Remove ManagerID column to fix 3NF

Solution

  1. Step 1: Identify transitive dependencies

    DepartmentID -> DepartmentName and ManagerID means non-key columns depend on another non-key column.
  2. Step 2: Normalize by splitting tables

    Create separate Department table with DepartmentID as key to remove transitive dependencies.
  3. Final Answer:

    Create two tables: one for Employees and one for Departments with DepartmentID as key -> Option C
  4. Quick Check:

    Split tables to remove transitive dependencies [OK]
Hint: Separate dependent columns into new table keyed by determinant [OK]
Common Mistakes:
  • Keeping all columns in one table ignoring transitive dependency
  • Adding columns to primary key unnecessarily
  • Removing important columns instead of normalizing
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard