Elaborate and experiment types of normalization.
Normalization is a process of designing a database schema to minimize data redundancy and
dependency. There are several levels of normalization, which are described below:
1. First Normal Form (1NF): In 1NF, all the attributes in a table must be atomic, i.e., indivisible.
Each column should have a single value, and no repeating groups or arrays should be allowed.
Every table should have a primary key that uniquely identifies each row. For example, consider
the following table:
Student ID Student Name Courses
001 Alice Math, Science
002 Bob English, History
2. This table is not in 1NF because the Courses column contains multiple values. To bring it into
1NF, we need to split it into a separate table, as shown below:
Student ID Student Name
001 Alice
002 Bob
Student ID Course
001 Math
Student ID Course
001 Science
002 English
002 History
4. Second Normal Form (2NF): In 2NF, the table should be in 1NF, and all non-key attributes
should be dependent on the entire primary key. In other words, there should be no partial
dependencies. For example, consider the following table:
Order ID Product ID Product Name Quantity
001 001 Pen 2
001 002 Pencil 3
002 001 Pen 4
002 003 Notebook 1
5. This table is not in 2NF because the Product Name column depends only on the Product ID, not
on the entire primary key (Order ID and Product ID). To bring it into 2NF, we need to split it
into two tables, as shown below:
Order ID Product ID Quantity
001 001 2
001 002 3
002 001 4
002 003 1
Product ID Product Name
001 Pen
002 Pencil
003 Notebook
7. Third Normal Form (3NF): In 3NF, the table should be in 2NF, and there should be no transitive
dependencies. In other words, no non-key attribute should depend on another non-key attribute.
For example, consider the following table:
Book ID Book Name Author Author Country
001 The Catcher in the Rye J.D. Salinger USA
002 To Kill a Mockingbird Harper Lee USA
003 Pride and Prejudice Jane Austen UK
8. This table is not in 3NF because the Author Country column depends on the Author column, not
on the primary key (Book ID). To bring it into 3NF, we need to split it into two tables, as shown
below:
Book ID Book Name Author ID
001 The Catcher in the Rye 001
002 To Kill a Mockingbird 002