The Wayback Machine - https://web.archive.org/web/20240719021213/https://www.geeksforgeeks.org/second-normal-form-2nf/
Open In App

Second Normal Form (2NF)

Last Updated : 22 May, 2024
Improve
Suggest changes
Post a comment
Like Article
Like
Save
Share
Report

First Normal Form (1NF) does not eliminate redundancy, but rather, it’s that it eliminates repeating groups. Instead of having multiple columns of the same kind of data in a record, (0NF or Unnormalized form) you remove the repeated information into a separate relation and represent them as rows. This is what constitutes 1NF. 

Second Normal Form

The second Normal Form (2NF) is based on the concept of fully functional dependency. The second Normal Form applies to relations with composite keys, that is, relations with a primary key composed of two or more attributes. A relation with a single-attribute primary key is automatically in at least 2NF. A relation that is not in 2NF may suffer from the update anomalies. To be in the second normal form, a relation must be in the first normal form and the relation must not contain any partial dependency. A relation is in 2NF if it has No Partial Dependency, i.e., no non-prime attribute (attributes that are not part of any candidate key) is dependent on any proper subset of any candidate key of the table. In other words,

A relation that is in First Normal Form and every non-primary-key attribute is fully functionally dependent on the primary key, then the relation is in Second Normal Form (2NF).

Note – If the proper subset of the candidate key determines a non-prime attribute, it is called partial dependency. The normalization of 1NF relations to 2NF involves the removal of partial dependencies. If a partial dependency exists, we remove the partially dependent attribute(s) from the relation by placing them in a new relation along with a copy of their determinant. Consider the examples given below.

Example-1: Consider the table as follows below.

STUD_NO            COURSE_NO        COURSE_FEE
1 C1 1000
2 C2 1500
1 C4 2000
4 C3 1000
4 C1 1000
2 C5 2000

{Note that, there are many courses having the same course fee. } Here, COURSE_FEE cannot alone decide the value of COURSE_NO or STUD_NO; COURSE_FEE together with STUD_NO cannot decide the value of COURSE_NO; COURSE_FEE together with COURSE_NO cannot decide the value of STUD_NO; Hence, COURSE_FEE would be a non-prime attribute, as it does not belong to the one only candidate key {STUD_NO, COURSE_NO} ; But, COURSE_NO -> COURSE_FEE, i.e., COURSE_FEE is dependent on COURSE_NO, which is a proper subset of the candidate key. Non-prime attribute COURSE_FEE is dependent on a proper subset of the candidate key, which is a partial dependency and so this relation is not in 2NF. To convert the above relation to 2NF, we need to split the table into two tables such as : Table 1: STUD_NO, COURSE_NO Table 2: COURSE_NO, COURSE_FEE

       Table 1                                    Table 2
STUD_NO COURSE_NO COURSE_NO COURSE_FEE
1 C1 C1 1000
2 C2 C2 1500
1 C4 C3 1000
4 C3 C4 2000
4 C1 C5 2000
2 C5

Note – 2NF tries to reduce the redundant data getting stored in memory. For instance, if there are 100 students taking C1 course, we dont need to store its Fee as 1000 for all the 100 records, instead once we can store it in the second table as the course fee for C1 is 1000. 

Example-2: Consider following functional dependencies in relation  R (A,   B, C,   D )

AB -> C  [A and B together determine C]
BC -> D [B and C together determine D]

Answer:

First, we can check if there are any partial dependencies. A partial dependency occurs when a non-prime attribute (not part of any candidate key) depends on only part of a candidate key.

The candidate keys for relation R can be determined by finding the closure of each attribute:

AB determines every keys.

Now, let’s check for partial dependencies:

There are no partial dependencies in this relation because each non-prime attribute (C and D) depends on the whole candidate key(s) it is part of (AB and BC, respectively).

Therefore, the relation R is already in 3rd Normal Form (3NF) because it satisfies the conditions of 1st Normal Form (1NF) and 2nd Normal Form (2NF) and does not have any transitive dependencies.

Conclusion

In conclusion, 2NF is a fundamental concept of database normalization that helps remove partial dependencies in your relational database. Following 2NF rules helps organize your database to avoid anomalies and ensure data integrity, making it easier to store and retrieve data.


Previous Article
Next Article

Similar Reads

Difference between 2NF and 3NF in DBMS
1. Second Normal Form (2NF) : A relation is said to be in second normal form when it is already in first normal form and there is no partial functional dependency that is no non-prime attribute should be functionally dependent on prime attribute. It was given by E.F Codd in 1971. If the candidate key comprises of only single attribute and relation
3 min read
Difference between 1NF and 2NF in DBMS
1. First Normal Form (1NF) : For any relation to be in the first normal form (1NF), the relation should not contain any composite or multi-valued attribute. So a relation will be in first normal form if it contains atomic values. The relation should contain only single valued attributes. Thus a relation that is in the first normal form must follow
3 min read
Converting Context Free Grammar to Chomsky Normal Form
Prerequisite - Simplifying Context Free Grammars A context free grammar (CFG) is in Chomsky Normal Form (CNF) if all production rules satisfy one of the following conditions: A non-terminal generating a terminal (e.g.; X->x) A non-terminal generating two non-terminals (e.g.; X->YZ) Start symbol generating ε. (e.g.; S-> ε) Consider the following gra
4 min read
Converting Context Free Grammar to Greibach Normal Form
Prerequisite - Context Free Grammars, Simplifying Context Free Grammars A context free grammar (CFG) is in Greibach Normal Form (GNF) if all production rules satisfy one of the following conditions: A non-terminal generating a terminal (e.g.; X->x)A non-terminal generating a terminal followed by any number of non-terminals (e.g.; X->xX1X2…XN)
4 min read
Domain Key Normal Form in DBMS
Prerequisites - Normal Forms, 4th and 5th Normal form, find the highest normal form of a relation It is basically a process in database to organize data efficiently. Basically there are two goals of doing normalization these are as follows: To remove repeated data or in simple words we can say to remove redundant data.Second one is to ensure that t
4 min read
What is PJNF(Project-Join Normal Form)?
Fifth normal form (5NF), is also known as project-join normal form (PJNF). It is a level of database normalization designed to reduce redundancy in relational databases. A relation is said to be in 5NF if and only if it satisfies 4NF and no join dependency exists. A relation is said to have join dependency if it can be recreated by joining multiple
2 min read
First Normal Form (1NF)
If a table has data redundancy and is not properly normalized, then it will be difficult to handle and update the database, without facing data loss. It will also eat up extra memory space and Insertion, Update, and Deletion Anomalies are very frequent if the database is not normalized. Normalization is the process of minimizing redundancy from a r
3 min read
Minimum Relations Satisfying First Normal Form (1NF)
A relation that does not contain any composite or multivalued attribute, then the relation is in its First Normal Form. Relations that contain a single-valued attribute comes under First Normal Form. In this article, we will be going to discuss the minimum relations satisfying the First Normal Form. Before proceeding to First Normal Form, let's dis
4 min read
Third Normal Form (3NF)
Although Second Normal Form (2NF)relations have less redundancy than those in 1NF, they may still suffer from update anomalies. If we update only one tuple and not the other, the database will be in an inconsistent state. This update anomaly is caused by a transitive dependency. We need to remove such dependencies by progressing to the Third Normal
3 min read
How to find the highest normal form of a relation
To understand this topic, you should have a basic idea about Functional Dependency & Candidate keys and Normal forms .Steps to find the highest normal form of relation: Find all possible candidate keys of the relation.Divide all attributes into two categories: prime attributes and non-prime attributes.Check for 1st normal form then 2nd and so o
5 min read
three90RightbarBannerImg