BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Normalization in DBMS: 1NF, 2NF, 3NF and BCNF in Database

Last Updated: May 5, 2022 by Chaitanya Singh | Filed Under: DBMS

Normalization is a process of organizing the data in database to avoid data redundancy, insertion anomaly, update anomaly & deletion anomaly. Let’s discuss about anomalies first then we will discuss normal forms with examples.

Anomalies in DBMS

There are three types of anomalies that occur when the database is not normalized. These are: Insertion, update and deletion anomaly. Let’s take an example to understand this.

Example: A manufacturing company stores the employee details in a table Employee that has four attributes: Emp_Id for storing employee’s id, Emp_Name for storing employee’s name, Emp_Address for storing employee’s address and Emp_Dept for storing the department details in which the employee works. At some point of time the table looks like this:

Emp_Id Emp_Name Emp_Address Emp_Dept
101 Rick Delhi D001
101 Rick Delhi D002
123 Maggie Agra D890
166 Glenn Chennai D900
166 Glenn Chennai D004

This table is not normalized. We will see the problems that we face when a table in database is not normalized.

Update anomaly: In the above table we have two rows for employee Rick as he belongs to two departments of the company. If we want to update the address of Rick then we have to update the same in two rows or the data will become inconsistent. If somehow, the correct address gets updated in one department but not in other then as per the database, Rick would be having two different addresses, which is not correct and would lead to inconsistent data.

Insert anomaly: Suppose a new employee joins the company, who is under training and currently not assigned to any department then we would not be able to insert the data into the table if Emp_Dept field doesn’t allow null.

Delete anomaly: Let’s say in future, company closes the department D890 then deleting the rows that are having Emp_Dept as D890 would also delete the information of employee Maggie since she is assigned only to this department.

To overcome these anomalies we need to normalize the data. In the next section we will discuss about normalization.

Normalization

Here are the most commonly used normal forms:

  • First normal form(1NF)
  • Second normal form(2NF)
  • Third normal form(3NF)
  • Boyce & Codd normal form (BCNF)

First normal form (1NF)

A relation is said to be in 1NF (first normal form), if it doesn’t contain any multi-valued attribute. In other words you can say that a relation is in 1NF if each attribute contains only atomic(single) value only.

As per the rule of first normal form, an attribute (column) of a table cannot hold multiple values. It should hold only atomic values.

Example: Let’s say a company wants to store the names and contact details of its employees. It creates a table in the database that looks like this:

Emp_Id Emp_Name Emp_Address Emp_Mobile
101 Herschel New Delhi 8912312390
102 Jon Kanpur 8812121212 ,
9900012222
103 Ron Chennai 7778881212
104 Lester Bangalore 9990000123,
8123450987

Two employees (Jon & Lester) have two mobile numbers that caused the Emp_Mobile field to have multiple values for these two employees.

This table is not in 1NF as the rule says “each attribute of a table must have atomic (single) values”, the Emp_Mobile values for employees Jon & Lester violates that rule.

To make the table complies with 1NF we need to create separate rows for the each mobile number in such a way so that none of the attributes contains multiple values.

Emp_Id Emp_Name Emp_Address Emp_Mobile
101 Herschel New Delhi 8912312390
102 Jon Kanpur 8812121212
102 Jon Kanpur 9900012222
103 Ron Chennai 7778881212
104 Lester Bangalore 9990000123
104 Lester Bangalore 8123450987

To learn more about 1NF refer this article: 1NF

Second normal form (2NF)

A table is said to be in 2NF if both the following conditions hold:

  • Table is in 1NF (First normal form)
  • No non-prime attribute is dependent on the proper subset of any candidate key of table.

An attribute that is not part of any candidate key is known as non-prime attribute.

Example: Let’s say a school wants to store the data of teachers and the subjects they teach. They create a table Teacher that looks like this: Since a teacher can teach more than one subjects, the table can have multiple rows for a same teacher.

Teacher_Id Subject Teacher_Age
111 Maths 38
111 Physics 38
222 Biology 38
333 Physics 40
333 Chemistry 40

Candidate Keys: {Teacher_Id, Subject}
Non prime attribute: Teacher_Age

This table is in 1 NF because each attribute has atomic values. However, it is not in 2NF because non prime attribute Teacher_Age is dependent on Teacher_Id alone which is a proper subset of candidate key. This violates the rule for 2NF as the rule says “no non-prime attribute is dependent on the proper subset of any candidate key of the table”.

To make the table complies with 2NF we can disintegrate it in two tables like this:
Teacher_Details table:

Teacher_Id Teacher_Age
111 38
222 38
333 40

Teacher_Subject table:

Teacher_Id Subject
111 Maths
111 Physics
222 Biology
333 Physics
333 Chemistry

Now the tables are in Second normal form (2NF). To learn more about 2NF refer this guide: 2NF

Third Normal form (3NF)

A table design is said to be in 3NF if both the following conditions hold:

  • Table must be in 2NF
  • Transitive functional dependency of non-prime attribute on any super key should be removed.

An attribute that is not part of any candidate key is known as non-prime attribute.

In other words 3NF can be explained like this: A table is in 3NF if it is in 2NF and for each functional dependency X-> Y at least one of the following conditions hold:

  • X is a super key of table
  • Y is a prime attribute of table

An attribute that is a part of one of the candidate keys is known as prime attribute.

Example: Let’s say a company wants to store the complete address of each employee, they create a table named Employee_Details that looks like this:

Emp_Id Emp_Name Emp_Zip Emp_State Emp_City Emp_District
1001 John 282005 UP Agra Dayal Bagh
1002 Ajeet 222008 TN Chennai M-City
1006 Lora 282007 TN Chennai Urrapakkam
1101 Lilly 292008 UK Pauri Bhagwan
1201 Steve 222999 MP Gwalior Ratan

Super keys: {Emp_Id}, {Emp_Id, Emp_Name}, {Emp_Id, Emp_Name, Emp_Zip}…so on
Candidate Keys: {Emp_Id}
Non-prime attributes: all attributes except Emp_Id are non-prime as they are not part of any candidate keys.

Here, Emp_State, Emp_City & Emp_District dependent on Emp_Zip. Further Emp_zip is dependent on Emp_Id that makes non-prime attributes (Emp_State, Emp_City & Emp_District) transitively dependent on super key (Emp_Id). This violates the rule of 3NF.

To make this table complies with 3NF we have to disintegrate the table into two tables to remove the transitive dependency:

Employee Table:

Emp_Id Emp_Name Emp_Zip
1001 John 282005
1002 Ajeet 222008
1006 Lora 282007
1101 Lilly 292008
1201 Steve 222999

Employee_Zip table:

Emp_Zip Emp_State Emp_City Emp_District
282005 UP Agra Dayal Bagh
222008 TN Chennai M-City
282007 TN Chennai Urrapakkam
292008 UK Pauri Bhagwan
222999 MP Gwalior Ratan

Boyce Codd normal form (BCNF)

It is an advance version of 3NF that’s why it is also referred as 3.5NF. BCNF is stricter than 3NF. A table complies with BCNF if it is in 3NF and for every functional dependency X->Y, X should be the super key of the table.

Example: Suppose there is a company wherein employees work in more than one department. They store the data like this:

Emp_Id Emp_Nationality Emp_Dept Dept_Type Dept_No_Of_Emp
1001 Austrian Production and planning D001 200
1001 Austrian stores D001 250
1002 American design and technical support D134 100
1002 American Purchasing department D134 600

Functional dependencies in the table above:
Emp_Id -> Emp_Nationality
Emp_Dept -> {Dept_Type, Dept_No_Of_Emp}

Candidate key: {Emp_Id, Emp_Dept}

The table is not in BCNF as neither Emp_Id nor Emp_Dept alone are keys.

To make the table comply with BCNF we can break the table in three tables like this:
Emp_Nationality table:

Emp_Id Emp_Nationality
1001 Austrian
1002 American

Emp_Dept table:

Emp_Dept Dept_Type Dept_No_Of_Emp
Production and planning D001 200
stores D001 250
design and technical support D134 100
Purchasing department D134 600

Emp_Dept_Mapping table:

Emp_Id Emp_Dept
1001 Production and planning
1001 stores
1002 design and technical support
1002 Purchasing department

Functional dependencies:
Emp_Id -> Emp_Nationality
Emp_Dept -> {Dept_Type, Dept_No_Of_Emp}

Candidate keys:
For first table: Emp_Id
For second table: Emp_Dept
For third table: {Emp_Id, Emp_Dept}

This table is now in BCNF as in both the functional dependencies left side part is a key.

❮ PreviousNext ❯

Top Related Articles:

  1. keys in DBMS
  2. Indexing in DBMS – Types of Indexes in Database
  3. Primary key in DBMS
  4. DBMS – First Normal Form (1NF)
  5. Instance and schema in DBMS

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Comments

  1. Mahak says

    November 17, 2015 at 8:14 AM

    Are you sure, that the example you given for Third Normal form (3NF) is correct. I have doubt, In the employee table and employee_zip table you relate ZIP in both tables but what If two employes having the same zip which record will be fetched from the employee_zip table ??

    Reply
    • Robert Luse says

      December 7, 2015 at 3:04 AM

      If two employees have the same zip, they will share the row in the zip table. There does not need to be two rows in the zip table and indeed, there should not be two rows in the zip table.

      Reply
      • harshal davane says

        April 5, 2017 at 6:51 PM

        WRONG IF WE CREATE NEW ZIP TABLE THEN WE CAN SEARCH THERE ZIP BYE NAME ALSO ..

        Reply
        • amit says

          April 22, 2017 at 8:13 PM

          name is not a prime attribute because multiple students can have same name and each student may have a different zip
          sagar -441124
          sagar -345632

          Reply
    • MUDASSIR AHMED says

      December 11, 2015 at 6:47 AM

      In employee table there will be 2 employees with same zip code but in employee_zip table there will be 1 record related to that zip code.The tables are related by zip code.So only 1 record will be fetched from employee_zip table. Hope you get the answer.

      Reply
    • Gulfam says

      December 14, 2015 at 10:41 AM

      Hey Mahak, there is only one record for every ZIP.

      ZIP in itself the complete address.

      Reply
    • Steve says

      December 16, 2015 at 10:30 PM

      Mahak, That is the point they are trying to make is that many employees could be related to 1 Zip record. There would only be 1 entry in the Zip table per zip, since that’s the key. That is the point of 3NF, is to denormalize the duplicate data in the Employee table. Good luck!

      Reply
    • DeepeshChaudhari says

      October 30, 2016 at 6:52 AM

      I think there is no issue related to emp_zip……
      becouse if any two employee have same emp_zip then it it means that both employee live’s in same area and so then in employee_zip table there is one row of that zip……..
      and data will be fetched from single row………………….

      Reply
  2. Robert Luse says

    December 7, 2015 at 3:08 AM

    As part of Normalization, there will be only one row for the the zip, not two. If two employees have the same zip, they will both use the information for that zip in the zip table.

    Reply
    • Omenesa says

      April 28, 2017 at 1:04 PM

      We should imagine a case scenario where two employees have the same zip code but different emp districts or emp city, which record will be fetched in such a scenario.

      Reply
  3. MUDASSIR AHMED says

    December 11, 2015 at 6:40 AM

    In BCNF “dept_no_of_emp” is also candidate key.

    Reply
  4. Kalpesh says

    March 9, 2016 at 6:40 AM

    Hi there,

    I have read whole article of Normalization and I must say, it a best explanation with examples.
    Examples are very useful for better understating the concept. I am really very thankful to you for the blog.
    Thank you.

    Reply
  5. Pushpa says

    May 5, 2016 at 7:48 AM

    Hi Chaitanya,

    The concept of normalization with example explained is very helpful. It helped me to understand it clearly.
    Thanks for sharing.

    Best Wishes,
    Pushpa

    Reply
  6. aman says

    May 27, 2016 at 7:18 PM

    This topic was not understandable from book .after reading this I finally got it. Thank u.

    Reply
  7. Sid says

    June 26, 2016 at 5:42 PM

    How is teacher_I’d, subject be the candidate key? Subject is redundant and only teacher I’d shld be sufficient.

    Reply
    • Harsh Rohila says

      July 14, 2016 at 3:43 PM

      Consider teacher_id 111, it is having two different subjects maths and physics. So only teacher_id cannot determine the complete row. Therefore subject is also required.

      Reply
    • Jaswinder says

      November 12, 2016 at 6:52 AM

      Teacher I’d alone cannot be the Candidate key because there will be many entries for a particular teacher as teacher can teach multiple subjects .And to fulfill criteria of becoming candidate key there should be unique values.

      Reply
    • Richard Kidd says

      November 28, 2016 at 7:51 PM

      A candidate key should be able to UNIQUELY IDENTIFY a row in a table. In the case of the teacher table, their are two rows in the table that can be identified with the teacher_id 111. If we are given teacher_id 111, we cannot discern if we need the record for subject ‘Maths’ or the record for subject ‘physics’. Therefore, teacher_id is not sufficient to uniquely identify a row. Likewise, as there are two rows with the teacher_id 111 and the teacher_age 38, these are also insufficient. The only minimal combination of attributes that uniquely identify a given row is {teacher_id, subject}.

      Reply
  8. Tharun Kumar Sunku says

    July 26, 2016 at 5:48 AM

    Superb explanation, Thank you for this valuable information

    Reply
  9. sandeep says

    August 30, 2016 at 11:49 AM

    hi chaitanya,
    you explained in a single table to partition into different tables so it is easy to understand but my doubt is to how to partition those tables so please provide some information about how to partition a table
    And also one thing before using those keys it is better to briefly explain about the keys so it is easy to understand

    Reply
  10. Seunfunmi says

    October 9, 2016 at 12:22 PM

    Very useful information. Thank you for this article. I read the textbook but did not understand. Now I understand 1NF and 2NF. I’m still not fully clear with the 3NF and the BCNF though. Pls anyone with more detailed information?

    Reply
  11. deepesh chaudhari says

    October 29, 2016 at 7:14 PM

    best notes of dbms forever……love it

    Reply
  12. Keynan says

    November 24, 2016 at 7:16 AM

    Hi
    Very good explanation.
    I have one question: dosen’t the example you gave on the BCNF(before the BCNF solution) also break the second rule? because non prime attributes depends on only subset of the candidate key? for an example: the dept_type and dept_no_of_emp are only depended on a subset of the candidate key which is emp_dept
    Thanks

    Reply
    • amit says

      April 22, 2017 at 8:29 PM

      In first table they are dependent, that is the violation of the 3NF. That’s why we decomposed the table and in second table Emp_dept is super key or candidate key not a subset of candidate key
      just like foreign key concept

      Reply
  13. Anugya says

    December 31, 2016 at 10:19 AM

    thnku for the making me understand the concept of normalization.

    Reply
  14. Rajiv Rai says

    January 17, 2017 at 5:23 AM

    Isn’t the attribute emp_zip also a candidate key(3NF example)? If yes then wouldnt it violate the 3NF rule in the next table?

    Reply
  15. PuddiMan says

    February 8, 2017 at 12:47 PM

    I don’t understand the example in BCNF. There are 2 primary keys, emp_id and emp_dept. This violates 2NF rules, emp_nationality can be determined by only emp_id. So in the first place, it is not in 2nf, why proceed to bcnf process?

    Someone care to explain/correct me please(if i’m wrong)

    Reply
  16. Ninja says

    February 12, 2017 at 9:08 AM

    Thanks a lot … 2morrow is my exam and this post really helped me.. Thanks a lot….

    Reply
  17. Yegon francis says

    April 24, 2017 at 9:15 AM

    Is it allowed to use two primary keys in a relationship table?

    Reply
  18. rahul says

    July 12, 2017 at 10:12 AM

    you should more explain ,candidate key ,and super key.
    it is very difficult to find

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

DBMS Tutorial

Basics

  • DBMS Tutorial
  • DBMS Introduction
  • Database Applications
  • DBMS vs File System
  • DBMS vs RDBMS
  • DBMS Architecture
  • Three-level DBMS architecture
  • View in DBMS
  • Abstraction
  • Instance & Schema
  • DBMS languages

Data Models

  • Data Models
  • ER Diagram
  • ER Design issues
  • Convert ER to table
  • DBMS Generalization
  • DBMS Specialization
  • DBMS Aggregration
  • Relational Model
  • Hierarchical Model
  • Constraints
  • Cardinality

Relational Database

  • RDBMS concepts
  • Relational Algebra
  • Relational Calculus
  • Keys Index
  • Primary Key
  • Super Key
  • Candidate Key
  • Foreign Key
  • Composite Key
  • Alternate Key

Normalization

  • Normalization
  • Functional dependency

Transaction Management

  • Transaction Management
  • ACID properties
  • Transaction States
  • DBMS Schedules
  • Serializability
  • Conflict Serializability
  • View Serializability
  • Recoverability Of Schedule
  • Failure Classification
  • Log based Recovery
  • DBMS Checkpoint
  • Deadlock

Concurrency Control

  • Concurrency Control
  • Lock based protocol
  • Timestamp based protocol
  • Validation based protocol

File Organization

  • File Organization
  • Sequential File Organization
  • Heap File Organization
  • Hash File Organization
  • DBMS ISAM
  • B+ File Organization
  • Cluster File Organization

SQL Introduction

  • SQL Introduction
  • SQL Characteristics
  • Advantages of SQL
  • SQL Commands
  • SQL Operators
  • SQL CREATE
  • SQL DROP
  • SQL SELECT
  • SQL INSERT

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap