You are currently viewing Normalization in DBMS with Example

Normalization in DBMS with Example

Share this to everyone:

Normalization is the process of organizing and structuring data in a database to minimize redundancy and improve efficiency. It involves breaking down a large table into smaller tables and establishing relationships between them.

Advantages of normalization:

  • Eliminates Redundancy: By breaking down data into smaller tables, normalization helps remove duplicate or redundant information. This improves data consistency and reduces storage space.
  • Improves Data Integrity: Normalization ensures that data is accurate and consistent across the database. By eliminating redundant data, it reduces the chances of inconsistencies or conflicting information.
  • Enhances Data Consistency: With normalized tables, updates or modifications need to be made in fewer places. This helps maintain data consistency, as changes are applied consistently throughout the database.
  • Simplifies Data Maintenance: Normalized tables are easier to maintain and update. Since data is divided into smaller, manageable tables, it becomes simpler to add, modify, or delete records without affecting other parts of the database.
  • Supports Efficient Querying: Normalization optimizes database performance by reducing data redundancy and establishing relationships between tables. This allows for faster and more efficient retrieval of information through queries.
  • Facilitates Scalability: Normalized databases are more scalable, as the structure is flexible and adaptable to changes. As new data needs arise, it is easier to expand the database without sacrificing efficiency or introducing inconsistencies.

Concept of 1NF,2NF and 3NF:

1NF, 2NF, and 3NF are abbreviations for the first three levels of database normalization. They represent first normal form, second normal form, and third normal form, respectively.

Additional normal forms beyond 3NF include 4NF (fourth normal form) and 5NF (fifth normal form). Although there is also 6NF (sixth normal form), the most commonly encountered normal form is 3NF.

Each level of normalization builds upon the previous ones. This means that the principles of 1NF are carried over to 2NF, and so on.

First Normal Form (1NF):

To satisfy the requirements of 1NF, a table must meet the following conditions:

  • Each cell should contain only a single value (atomicity).
  • A primary key must exist for unique identification.
  • There should be no duplicate rows or columns.
  • Each column should have only one value for each row in the table.

Second Normal Form (2NF):

While 1NF eliminates repeating groups, it does not address redundancy. Therefore, 2NF was introduced.

A table is considered to be in 2NF if it fulfills the following criteria:

  • It already satisfies 1NF requirements.
  • No partial dependencies exist. In other words, all non-key attributes are fully dependent on the primary key.

Third Normal Form (3NF):

When a table is in 2NF, it removes repeating groups and redundancy. However, it may still have transitive partial dependencies.

This means that a non-prime attribute (an attribute that is not part of the candidate key) depends on another non-prime attribute. The purpose of the third normal form (3NF) is to eliminate such dependencies.

Therefore, for a table to be in 3NF, it must:

  • Be in 2NF.
  • Have no transitive partial dependencies.

Examples:

Let us consider the following table:

Employee_IdNameJob_CodeJobState_CodeHome_State
E01RamJ01 J02Chef Waiter26Damak
E02HariJ02 J03Waiter Bartender56Urlabari
E03KripaJ01Chef56Urlabari

The above table is not in 1NF as it contains non-atomic value. So, making the table in 1 NF as follows:

Employee_IdNameJob_CodeJobState_CodeHome_State
E01RamJ01Chef26Damak
E01RamJ02Waiter26Damak
E02HariJ02Waiter56Urlabari
E02HariJ03Bartender56Urlabari
E03KripaJ01Chef56Urlabari

The table is now in 1NF but not in 2NF because,

With Employee_id, we can know Name, State_Code and Home_State. This means they are dependent on Employee_Id. Now separating the table into two tables, attribute dependent on Employee_Id & attribute independent on Employee_ID:

Employees table:

Employee_IdNameState_CodeHome_State
E01Ram26Damak
E02Hari56Urlabari
E03Kripa56Urlabari

Employee_Roles table:

Employee_IdJob_Code
E01J01
E01J02
E02J02
E02J03
E03J01

Jobs table:

Job_CodeJob
J01Chef
J02Waiter
J03Bartender

Now the tables are in 2NF but not in 3NF because,

Home_state depends on State_code.

So breaking Employees table into two tables,

Employees table:

Employee_IdNameState_Code
E01Ram26
E02Hari56
E03Kripa56

State table:

State_CodeHome_State
26Damak
56Urlabari

Employee_Roles table:

Employee_IdJob_Code
E01J01
E01J02
E02J02
E02J03
E03J01

Jobs table:

Job_CodeJob
J01Chef
J02Waiter
J03Bartender

Hence the tables are in 3NF.