In this part, I will be briefing about different types of Database Normalizations using a sample data model.

What is Database Normalization?

Normalization is the process of efficiently organizing data in the database.

Primary Goal of Normalization?

Eliminating redundant data & ensuring meaningful data dependencies.

Types of Normalization

The following are the three most common normal forms in the database normalization process

  1. First Normal Form (1NF)
  2. Second Normal Form (2NF)
  3. Third Normal Form (3NF)

Sample Data Model for Demonstration

The following data model will be used to demonstrate all the three normal forms

data_model

First Normal Form (1NF)

First Normal Form (1NF) sets the very basic rules for an organized database:

  • Create separate set of tables for each group of related data and identify each row with a unique columns [primary key] or set of columns [composite key]
  • Eliminate duplicate columns from the table

The following data model depicts the tables after 1NF rules are applied -

first_normal_form

Second Normal Form (2NF)

Second Normal Form (2NF) further addresses the concept of removing duplicate data:

  • Meet all the requirements of the first normal form
  • Remove subsets of data that apply to multiple rows of a table and place them in separate tables
  • Create relationships between these new tables and their predecessors through the use of foreign keys

So basically the objective of the Second Normal Form is to take that is only partly dependent on the primary key and enter that data into another table.

The following data model depicts the tables after 2NF rules are applied.

Data from EMPLOYEE_TABLE is split into 2 tables – EMPLOYEE_TABLE and EMPLOYEE_HR_TABLE.

second_normal_form_1

Similarly data from CUSTOMER_TABLE is moved to CUSTOMER_TABLE and CUSTOMER_ORDER table

second_normal_form_2

Third Normal Form (3NF)

Third normal form (3NF) goes one large step further:

  • Meet all the requirements of the second normal form.
  • Remove columns that are not dependent upon the primary key.

The following data model depicts the tables after 3NF rules are applied.

third_normal_form_1

Further state and country details are moved to their own tables because they are not dependent on the primary key.

third_normal_form_2

Advantages of Normalizing the Database

There are several advantages of normalization -

  1. Data can be stored as small atomic pieces
  2. Saves space
  3. Increases speed
  4. Reduces data anomalies
  5. Easy maintenance

Other parts of this series include:

Part 1 – ACID Properties

Part 2 – Keys

Part 4 – Database Transactions [coming soon]

Part 5 – Indexes [coming soon]


4 Comments

  1. Capn Pants
    March 13, 2013 at 6:21 pm

    In disadvantages you could include that meaningful data extraction can be more difficult and some data access can be slower.

    Reply
  2. エイプ ブランド
    September 12, 2013 at 2:33 am

    エイプ ファッション

    Reply
  3. Database Concepts for Java Programmer: Part 2 - KeysSkilledMonster
    October 23, 2013 at 7:39 am

    […] parts of this series include: Part 1 – ACID Properties Part 3 – Normalization Part 4 – Database Transactions [coming soon] Part 5 – Indexes [coming […]

    Reply
  4. My Homepage
    April 25, 2014 at 12:36 pm

    … [Trackback]

    [...] Read More: skilledmonster.com/2013/03/01/database-normalization/ [...]

    Reply

Leave a comment