Unit3-Part2-Normalization-Normal Forms
Unit3-Part2-Normalization-Normal Forms
• It provides a method to remove the following anomalies from the database and bring it to a more
consistent state:
• A database anomaly is a flaw in the database that occurs because of poor planning and redundancy.
• Insertion anomalies: This occurs when we are not able to insert data into a database because some
attributes may be missing at the time of insertion.
• Updation anomalies: This occurs when the same data items are repeated with the same values and
are not linked to each other.
• Deletion anomalies: This occurs when deleting one part of the data deletes the other necessary
information from the database.
Normal Forms
Normal Forms
• 1NF: A relation is in 1NF if all its attributes have an atomic value.
• 2NF: A relation is in 2NF if it is in 1NF and all non-key attributes are fully functional dependent
on the candidate key in DBMS.
• BCNF: A relation is in BCNF if it is in 3NF and for every Functional Dependency, LHS is the
super key.
• The normalization of 1NF relations to 2NF involves the elimination of partial dependencies.
• A partial dependency in DBMS exists when any non-prime attributes, i.e., an attribute not a
part of the candidate key, is not fully functionally dependent on one of the candidate keys.
• For a relational table to be in second normal form, it must satisfy the following rules:
In the above table, the prime attributes of the table are Employee Code and Project ID.
We have partial dependencies in this table because Employee Name can be determined
by Employee Code and Project Name can be determined by Project ID. Thus, the above
relational table violates the rule of 2NF.
• To remove partial dependencies from this table and normalize it into
2NF second normal form, we can decompose the
<EmployeeProjectDetail> table into the following three tables:
2NF
• Thus, we’ve converted the <EmployeeProjectDetail> table into 2NF
by decomposing it into <EmployeeDetail>, <ProjectDetail> and
<EmployeeProject> tables.
• The above tables satisfy the following two rules of 2NF as they are in
1NF and every non-prime attribute is fully dependent on the primary
key.
• The relations in 2NF are clearly less redundant than relations in 1NF.
However, the decomposed relations may still suffer from one or more
anomalies due to the transitive dependency.
• We will remove the transitive dependencies in the Third Normal Form.
Third Normal Form (3NF)
The above table is not in 3NF because it has Employee Code -> Employee
City transitive dependency because:
•Employee Code -> Employee Zipcode
•Employee Zipcode -> Employee City
Also, Employee Zipcode is not a super key and Employee City is not a
prime attribute.
3NF
• For a relational table to be in Boyce-Codd normal form, it must satisfy the following
rules:
The above table satisfies all the normal forms till 3NF, but it violates the rules of
BCNF because the candidate key of the above table is
{Employee Code, Project ID}.
For the non-trivial functional dependency,
Project Leader -> Project ID, Project ID is a prime attribute, but Project Leader is a
non-prime attribute. This is not allowed in BCNF.
BCNF