Database Normalization
Database Normalization
The inventor of the relational model Edgar Codd proposed the theory of normalization with the
introduction of the First Normal Form, and he continued to extend theory with Second and Third
Normal Form.
The Theory of Data Normalization in SQL is still being developed further. For example, there are
discussions even on 6 Normal Form. However, in most practical applications, normalization
Achieves its best in 3 Normal Form. The evolution of Normalization theories is illustrated below-
1
1NF (First Normal Form) Rules
1NF Example
Tableau 2
What is a KEY?
A KEY is a value used to identify a record in a table uniquely. A KEY could be a single column or
combination of multiple columns
Note: Columns in a table that are NOT used to identify a record uniquely are called non-key
columns.
In our database, we have two people with the same name Robert Phil, but they live in different
places.
Hence, we require both Full Name and Address to identify a record uniquely. That is a composite
key.
Rule 1- Be in 1NF
Rule 2- Single Column Primary Key
3
It is clear that we can't move forward to make our simple database in 2 Normalization form
unless we partition the table above.
Tableau 3
Tableau 4
We have divided our 1NF table into two tables. Table 3 and Table4. Table 3 contains member
information. Table 4 contains information on movies rented.
We have introduced a new column called Membership_id which is the primary key for table 3.
Records can be uniquely identified in Table 3 using membership id
Foreign Key references the primary key of another Table! It helps connect your Tables
Foreign Key references the primary key of another Table! It helps connect your Tables
A foreign key can have a different name from its primary key
Unlike the Primary key, they do not have to be unique. Most often they aren't
Foreign keys can be null even though primary keys can not
4
Why do you need a foreign key? Suppose, a novice inserts a record in Table B such as
You will only be able to insert values into your foreign key that exist in the unique key in the parent
table. This helps in referential integrity.
The above problem can be overcome by declaring membership id from Table4 as foreign key of
membership id from Table3
5
Now, if somebody tries to insert a value in the membership id field that does not exist in the parent
table, an error will be shown!
Consider the table 1. Changing the non-key column Full Name may change Salutation.
Rule 1- Be in 2NF
Rule 2- Has no transitive functional dependencies
To move our 2NF table into 3NF, we again need to divide our table.
3NF Example
Tableau 5
We have again divided our tables and created a new table which stores Salutations.
6
There are no transitive functional dependencies, and hence our table is in 3NF
In Table 5 Salutation ID is primary key, and in Table 1 Salutation ID is foreign to primary key in
Table 5
Now our little example is at a level that cannot further be decomposed to attain higher normal
forms of normalization. In fact, it is already in higher normalization forms. Separate efforts for
moving into next levels of normalizing data are normally needed in complex databases. However,
we will be discussing next levels of normalizations in brief in the following.
Even when a database is in 3 Normal Form, still there would be anomalies resulted if it has more
than one Candidate Key.
A table is in 5 Normal Form only if it is in 4NF and it cannot be decomposed into any number of
smaller tables without loss of data.
6 Normal Form is not standardized, yet however, it is being discussed by database experts for some
time. Hopefully, we would have a clear & standardized definition for 6 Normal Form in the near
future...
Summary
Database designing is critical to the successful implementation of a database management system
that meets the data requirements of an enterprise system.
Normalization in DBMS helps produce database systems that are cost-effective and have
better security models.
Functional dependencies are a very important component of the normalize data process
Most database systems are normalized database up to the third normal forms.
A primary key uniquely identifies are record in a Table and cannot be null
A foreign key helps connect table and references a primary key