What is the First Normal Form?
Before understanding the First Normal Form, one must know what Normalization is and why it is done? Normalization, in general terms, is the technique of organizing the data into the database to reduce the insertion, deletion and updation anomaly and remove data redundancy. This process divides the larger tables into smaller ones and links them with each other through relationships of the primary and foreign keys. Duplicate and unnormalized data not only consumes extra memory but makes it difficult to manage the table while insertion, deletion, and updation of tables as the number of data increases. Therefore it is very important to normalize the tables before designing the database of any application.
First Normal Form, written as 1NF , sets the fundamental rules of data normalization and is the first form used while normalizing the data of tables. It sets certain basic principles of data normalization, which needs to be fulfilled by every table. Some of the principles are given below:
- Every column should have single atomic (values which cannot be divided further) values.
- Each column in the table does not have composite values and repeating values, as it makes it difficult to search the values for the column having multiple values. So every column must have a single unique value.
- Values stored in a column should be of the same domain to be in 1NF.
- All the columns present in the table should have unique names.
- A table must have a unique Primary key that is used to identify each record differently.
How does First Normal Form Works?
According to the main principles of 1NF mentioned above,
- There should not be composite values for a column that can be divided further; if a column in a table has a value that can be divided further, then a separate table should be created for that attribute with different columns in that table with a unique Primary Key. For example, in an Employee table, for the employee_address, which can be divided further, there should be a separate table of Employee_address having Employee_id as its Primary Key and House No, City and Pincode as different columns.
Table Employee (before 1NF)
|101||Raghu||25||Xyz colony, Agra, 258996|
|102||Rakesh||28||Flat 304, xyz road, Lucknow, 568975|
|103||Rahul||45||House no .123, near a hospital, Varanasi, 245687|
As the Emp_address has so much data for address, for a single Employee, To be in 1NF, the above table can be decomposed into two below given tables:
Table1: Employee_details (After 1NF)
Table2: Employee_address (After 1NF)
|101||House no. 564, Xyz colony||Agra||258996|
|102||Flat 304, xyz road||Lucknow||568975|
|103||House no .123, near a hospital||Varanasi||245687|
There should be atomic values for a column that is indivisible in 1NF. For example, there can be multiple Emp_projects that he/she has handled in an Employee table until now. In order to have a record of all the projects of that employee, there should be a separate record for each project of an employee having unique value instead of projects being separated by ‘, ‘
Table: Emp_projects (Before 1NF)
|103||5||Accounts||Abc, cfg,xyz, hjk|
Table: Emp_projects (After 1NF)
Table: Emp_projects having multiple repeating values in the above example can be broken down further into two tables to reduce repetition:
There should not be repeating values present in the table. Repeating values consumes a lot of extra memory and makes the search and update slow and maintenance of the database difficult. For example, In the above table of Employee_Projects, there are a lot of unnecessary repeating values of Emp_id, Emp_years_of_experience, and Emp_dept, so a new table needs to be created for this in order to reduce the repetition of values.
Advantages of First Normal Form
Below given are some of the advantages of the First Normal Form (1NF):
- One of the primary advantages of 1NF is that it removes the unnecessary repeating values by creating a separate table and hence does not create any issue while inserting, deleting and updating the values in the database.
- Working with the tables having the columns with multiple values separated by ‘,’ is very difficult while searching for a specific value in the database by splitting all the values of a column and again converting them in a specific format, wasting a lot of time and memory in it. 1NF makes it easy by creating different rows for different values.
- 1NF forms the basis and is the foremost principle that is followed while creating a database and hence is the most important Normal Form for the tables to proceed further to be normalized with 2NF and 3NF.
- 1NF is important as it creates a Functional dependency between the two tables using the Primary Key and Foreign Key, which plays a crucial role while working with tables of a database.
- 1NF allows users to use the database queries effectively as it removes ambiguity by removing the null and multiple values of a column which creates major issues in the future while updating and extracting the database.
While working with the databases and creating tables for any application in the starting, it is very important to normalize all the tables as it helps to eliminate insertion, deletion, and update anomalies. Normalization also removes future costs and time. Fewer null values and lesser redundant data makes the database more compact. Through Normalization, more tables are created, which helps in the easy and efficient maintenance of data. Through Normalization, obviously, the better performance of searching and sorting is ensured through indexes and keys, and 1NF plays a vital role in it.
This is a guide to First Normal Form. Here we discuss the Definition, Working, and Advantages of the First Normal Form along with its Examples. You may also look at the following articles to learn more –