First Normal Form (1NF) | normalization and its types
FIRST NORMAL FORM(1NF)
A relation is said to be in first normal form, if it satisfies the following rules.
- There are no duplicate rows i.e. all the primary key attributes are defined.
- There are no repeating groups in the table i.e. each rows and columns intersection contains one and only one value and not a set of vales.
The first normal form does not allows a relations to contain nested relations.
E.G-Consider a relation "record"
St_id
|
St_name
|
subject
|
marks
|
101
|
Amrit
|
Computer
Economics
Maths
|
98
56
43
|
102
|
Anupreet
|
Maths
Eco
|
98
99
|
It is not in 1NF
HOW TO CONVERT IT INTO 1NF?
METHOD 1
STEP 1-To remove repeating values for a column the record relation is converted to a flat relation i.e. STU1 by repeating the pair having composite primary key (St_id,St_name)
STEP 2- For every entry in the table consequently removing the attribute record with its sub-ordinate attributes.
Relation "STU1"
St_id
|
St_name
|
subject
|
marks
|
101
|
Amrit
|
Computer
|
98
|
101
|
Amrit
|
Economics
|
56
|
101
|
Amrit
|
Maths
|
43
|
102
|
Anupreet
|
Maths
|
98
|
102
|
Anupreet
|
Eco
|
99
|
It is in 1NF but this method increases redundancy.
METHOD 2
Another method is to remove the attributes that violates the first normal form and place it in a separate relation along with the primary key.So, un-normalized relation("record") is decomposed into 2 sub-relations .
(stu_details),(stu_performance)
Relation (stu_details)
St_id
|
St_name
|
101
|
Amrit
|
102
|
Anupreet
|
Relation (stu_performance)
St_id
|
subject
|
marks
|
101
|
Computer
|
98
|
101
|
Economics
|
56
|
101
|
Maths
|
43
|
102
|
Maths
|
98
|
102
|
Eco
|
99
|
It is in 1NF.
Anomalies -Insertion,deletion and updation anomaly
Great post...this one helped me understand more too: example of first normal form
ReplyDelete