DEV Community

Cover image for 1NF and 2NF
hebaShakeel
hebaShakeel

Posted on

1NF and 2NF

Normalization: It is a way to reduce/minimize data redundancy (repetition of data). It can be achieved by splitting the table into many tables.

First Normal Form (1NF):
-> It is the property of converting ER Diagram into the Relational Database.
-> The Relational Database is implicitly in 1NF.
-> All attributes should be atomic [ only one value in a tuple is allowed].

Example
Alt Text
Here, SMobile has multiple values which are not allowed. They have to be taken individually.

Approach-1
Alt Text
This approach creates a lot of redundancy in the table. Therefore it is not a suitable approach.

Approach-2
Alt Text
This approach also has redundancy but less when compared to the previous Approach. This is because the tables have now been split into two.

Prime Attributes(Key):
Those attributes which participate in the Candidate key.
Example 1
R(ABCD), CKs: {A, BD}
Therefore PA = {A,B,D}

Example 2
R(ABCDEFG), CKs: {AB, BC, CD, F}
Therefore PA = {A,B,C,D,F}

Non-Prime Attributes(Non-Key):
Those attributes which do not participate in Candidate Key.
Example 1
R(ABCD), CKs: {A, BD}
Therefore NPA = {C}

Example 2
R(ABCDEFG), CKs: {AB, BC, CD, F}
Therefore NPA = {E,G}

Partial Dependency:
If subset of any Candidate Key derives a non-key attribute.

Example
R(ABCD) FDs : {AB->CD, B->D}
CK => {AB}
B->D, B is a subset of AB and it derives non-key, therefore it is a partial dependency.

Second Normal Form (2NF):
=> If a relation 'R' is in 1NF (and)
=> If every non-prime attribute is fully dependent on any complete CK (or) No Partial Dependency exists.

Allowed in 2NF:
=> Non-Prime determines Non-Prime
=> Non-Prime determines Prime
=> Prime determines Prime

Not-Allowed in 2NF:
=> Prime determines Non-Prime

Top comments (0)