First Normal Form in SQL
First Normal Form in DataBase
First Normal Form (1NF) is a property of a relation in a relational database. A relation is in first normal form if and only if the domain of each attribute contains only atomic (indivisible) values, and the value of each attribute contains only a single value from that domain.
1st Normal Form
In this normal form user need to remove the multi-value attribute on the table. For a table to be in the First Normal Form, it should follow the following 4 rules:
- It should only have single(atomic) valued attributes/columns
- Values stored in a column should be of the same domain
- All the columns in a table should have unique names
- And the order in which data is stored, does not matter
There are no duplicate rows and each row should have a unique identifier (or Primary key). A table should be free from repeating groups.
The values in each column of a table are atomic. Meaning a field value cannot be decomposed into smaller pieces or should not be divided into parts with more than one kind of data in it.Like: A Person's Name column could be further divided into First, Middle, Last Name columns.
Example: Relation Department is not in 1NF because of multi-valued attribute Subject.
Roll_no | Name | SUBJECT |
---|---|---|
100 | Faiz | JAVA |
101 | Rama | C++, JAVA |
102 | Hitesh | ANDROID |
103 | Sultan | C,C++ |
106 | Mahendra | PHP |
The decomposition of the Department table into 1NF has been shown below:
Roll_no | Name | SUBJECT |
---|---|---|
100 | Faiz | JAVA |
101 | Rama | C++, JAVA |
101 | Rama | JAVA |
102 | Hitesh | ANDROID |
103 | Sultan | C,C++ |
103 | Sultan | C++ |
106 | Mahendra | PHP |