What is the first normal form in SQL?
Normal form
Normal form or normalization is used to reduce the redundancy from a relation.
In normalization, we divide the larger tables into smaller ones.
First normal form
If a relation contains an atomic value, it is said to be in the first standard form.
-
First normal form states that we cannot have multiple values for the same attribute in a table.
-
One table only should have a single-valued attribute in the first standard form.
Master table
Name | Id | Course |
Rakesh, Suresh | 10 | CSE |
Ganesh, Shyam, Ram | 16 | ECE |
Harika, Vishwa , Don | 13 | EEE |
Explanation
-
In the table above, we have the
Nameattribute as a multi-value attribute, which violates the first normal form. -
Hence, we must decompose the table into two smaller tables to follow the first standard form.
-
Decomposition is carried out so that we can get the required table that follows the first normal form.
Decomposed table 1
Name | Id |
Rakesh | 10 |
Suresh | 10 |
Ganesh | 16 |
Shyam | 16 |
Ram | 16 |
Harika | 13 |
Vishwa | 13 |
Don | 13 |
Decomposed table 2
Id | Course |
10 | CSE |
16 | ECE |
13 | EEE |
-
The “Master table” is decomposed into two smaller tables to meet our criteria.
-
After we decompose the table, the multi-valued attribute is split into single-value attributes.