Normalization in SQL Server
Normalization is the process of organizing data to minimize data redundancy (data duplication), which in turn ensures data consistency.
Note: Data redundancy can lead to inconsistency data.
The problem of data redundancy
- Disk space wastage
- data inconsistency
- DML queries can be slow
There are five types for normalization
First Normal Form (1st NF):
- Identify data with primary key
- the data in each column should be atomic no multiple value in column
Second Normal Form (2nd NF):
Create separate tables for sets of values and Relate these tables with a foreign key.
Third Normal Form (3rd NF):
Eliminate fields that do not depend on the primary key.
Other normalization forms:
They are rarely considered in practical design. Disregarding these rules may result in less than perfect database design, but should not affect functionality.
Normalization Example
To apply normalization on the Product table will divide the table into two tables Product and department as shown below .This example for third normal form:
-Eliminate redundant data you create Department table that contain DepartmentID and DepartmentName
-Set DepartmentID as primary key
-In Product table set ID as primary key and DepartmentID is foreign key to make relation between two tables
-Now