1st 2nd 3rd Normal Form Example

5 min read

Understanding Database Normalization: A Practical Guide to 1st, 2nd, and 3rd Normal Forms with Examples

Database normalization is the systematic process of organizing the columns (attributes) and tables (relations) of a relational database to reduce data redundancy and improve data integrity. Practically speaking, it involves dividing larger tables into smaller, related tables and defining relationships between them. The ultimate goal is to isolate data so that additions, deletions, and modifications can be made in just one table before propagating through the rest. This article will break down the first three normal forms, which are the most fundamental, using clear, practical examples No workaround needed..

Introduction: Why Normalize?

Before diving into the specific forms, it's crucial to understand the problems normalization solves. Worth adding: this is an unnormalized table. Imagine a simple company that keeps all its information—employee details, department details, and project assignments—in one massive, single table. While it might work for a tiny dataset, it quickly becomes a nightmare as the company grows Which is the point..

The issues are significant:

  • Data Redundancy: The same information, like a department name or address, is stored multiple times for different employees. Forgetting to update one record leads to inconsistency. That said, this wastes storage space. * Insertion Anomalies: You cannot add a new department with no employees yet because the table structure might require an employee ID for every row.
  • Update Anomalies: If the Marketing department moves to a new address, you would have to update that address for every single employee in the Marketing department. * Deletion Anomalies: If the last employee in the "Project Alpha" team is deleted, all information about "Project Alpha" itself might be lost.

This is where a lot of people lose the thread.

Normalization systematically addresses these problems by breaking the data into logical, related tables.


First Normal Form (1NF): Atomicity and Eliminating Repeating Groups

The first normal form is the foundational rule. A table is in First Normal Form (1NF) if:

  1. Each column contains atomic (indivisible) values.
  2. Also, each column contains values of the same data type. 3. There are no repeating groups of columns. This means you cannot have a column like Phone1, Phone2, Phone3 to store multiple phone numbers for a single customer.

Worth pausing on this one Turns out it matters..

Example: Violating 1NF

Consider an unnormalized Customer table designed to store customer information and their multiple phone numbers.

CustomerID Name PhoneNumbers
1 Alice 555-1234, 555-5678
2 Bob 555-8765
3 Charlie 555-1111, 555-2222, 555-3333

This table violates 1NF because the PhoneNumbers column contains a list of values, not a single, atomic value. It's a repeating group.

Achieving 1NF

To bring this table into 1NF, we must eliminate the repeating group. We do this by creating a separate table for phone numbers and linking it back to the customer.

Customer Table (in 1NF)

CustomerID Name
1 Alice
2 Bob
3 Charlie

PhoneNumber Table (in 1NF)

PhoneNumberID CustomerID PhoneNumber
1 1 555-1234
2 1 555-5678
3 2 555-8765
4 3 555-1111
5 3 555-2222
6 3 555-3333

Now, each column has atomic values, and the relationship is maintained via the CustomerID foreign key. This structure is much more flexible and solid Which is the point..


Second Normal Form (2NF): Removing Partial Dependencies

A table is in Second Normal Form (2NF) if it meets all the rules of 1NF and, additionally, has no partial dependencies. A partial dependency occurs when a non-key attribute (a column that is not part of the primary key) is functionally dependent on only a part of a composite primary key (a primary key made of more than one column) Simple, but easy to overlook..

This rule only applies to tables with composite primary keys. The goal is to make sure all non-key attributes are fully dependent on the entire primary key, not just a piece of it Small thing, real impact. Turns out it matters..

Example: Violating 2NF

Let's consider a table that tracks which employees work on which projects, and the date they started on that project. We also want to record the employee's department.

ProjectAssignment Table (Violates 2NF)

EmployeeID ProjectID StartDate Department
101 P100 2023-01-15 Sales
102 P100 2023-02-01 Engineering
101 P200 2023-03-10 Sales
  • Primary Key: (EmployeeID, ProjectID) - a composite key.
  • Non-Key Attributes: StartDate, Department.

Here lies the problem: The Department attribute depends only on the EmployeeID, not on the ProjectID. Day to day, this is a partial dependency. If an employee changes departments, we would have to update the Department field in multiple rows, risking inconsistency But it adds up..

Achieving 2NF

To resolve this, we split the table to remove the partial dependency. We create a new table for employee details, where EmployeeID is the primary key And that's really what it comes down to..

ProjectAssignment Table (in 2NF)

EmployeeID ProjectID StartDate
101 P100 2023-01-15
102 P100 2023-02-01
101 P200 2023-03-10

Employee Table (in 2NF)

EmployeeID Department
101 Sales
102 Engineering

Now, the Department is fully dependent on the primary key of the Employee table (EmployeeID), and the ProjectAssignment table only contains attributes (StartDate) that are fully dependent on its composite key (EmployeeID, ProjectID).


Third Normal Form (3NF): Removing Trans

New and Fresh

Straight to You

These Connect Well

Good Company for This Post

Thank you for reading about 1st 2nd 3rd Normal Form Example. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home