You are on page 1of 9

Section 1: Database Normalisation Page |1

Database Normalisation

What is Database Normalisation?

Database normalization is a technique for creating database tables with


suitable columns and keys by decomposing a large table into smaller logical
units.

What is the purpose of Database Normalisation?

1. To Eliminate the redundant or useless data.


2. To Reduce the complexity of the data.
3. To Ensure the relationship between tables as well as data in the tables.
4. To Ensure data dependencies and data is logically stored.

Database Redundancies and Anomalies

When altering an entity in a table with redundancies, you must modify all
repeated instances of information, and any other information related to the
changed data. Otherwise, the database becomes inconsistent and anomalies
happen when making changes.

For example, in the following unnormalized table:

1. Insert anomaly - When trying to insert a new employee in the finance sector,
you must also know the manager's name. Otherwise, you cannot insert data into
the table.

2. Update anomaly - If an employee switches sectors, the manager's name ends


up being incorrect. For example, if Jacob changes to finance, Adam stays as his
manager.
Section 1: Database Normalisation Page |2

3. Delete anomaly - If Joshua decides to leave the company, deleting the row
also removes the information that a finance sector exists.

The solution to these anomalies is in database normalization concepts and


steps.

Database Normalization Concepts

Concepts used in database normalization are:

 Keys. Column attributes that identify a database record uniquely.


 Functional Dependencies. Constraints between two attributes in a
relation.
 Normal Forms. Steps to accomplish a certain quality of a database.

Database Normal Forms

Normalizing a database is achieved through a set of rules known as normal


forms. The central concept is to help a database designer achieve the desired
quality of a relational database.

All levels of normalization are cumulative. Previous normal form requirements


must be satisfied before moving on to the following form.
Section 1: Database Normalisation Page |3

Stages of normalization are:

Stages Redundancy Anomalies Addressed

Unnormalized Form (UNF) The state before any normalization.


Redundant and complex values are
present.

First Normal Form (1NF) Repeating and complex values split up,
making all instances atomic.

Second Normal Form (2NF) Partial dependencies decompose to


new tables. All rows functionally
depend on the primary key.

Third Normal Form (3NF) Transitive dependencies decompose to


new tables. Non-key attributes depend
on the primary key.

Boyce-Codd Normal Form (BCNF) Transitive and partial functional


dependencies for all candidate keys
decompose to new tables.

Fourth Normal Form (4NF) Removal of multivalued dependencies.

Fifth Normal Form (5NF) Removal of JOIN dependencies.

Functional Database Dependencies

A functional database dependency represents a relationship between two


attributes in a database table. Some types of functional dependencies are:

 Trivial Functional Dependency. A dependency between an attribute and


a group of features where the original element is in the group.
 Non-Trivial Functional Dependency. A dependency between an attribute
and a group where the feature is not in the group.
Section 1: Database Normalisation Page |4

 Transitive Dependency. A functional dependency between three


attributes where the second depends on the first and the third depends on
the second. Due to transitivity, the third attribute is dependent on the first.
 Multi-valued Dependency. A dependency where multiple values depend
on one attribute.

Functional dependencies are an essential step in database normalization. In the


long run, the dependencies help determine the overall quality of a database.

Database Normalization Example

How to Normalize a Database?

The general steps in database normalization work for every database. The
specific steps of dividing the table as well as whether to go past 3NF depend on
the use case.

Example Unnormalized Database

An unnormalized table has multiple values within a single field, as well as


redundant information in the worst case.

*Inserting, updating, and removing data is a complex task. Performing any


alterations to the existing table has a high risk of losing information.
Section 1: Database Normalisation Page |5

Step 1: First Normal Form 1NF

To rework the database table into the 1NF, values within a single field
must be atomic. All complex entities in the table divide into new rows or
columns.

The information in the columns managerID, managerName, and area


repeat for each employee to ensure no loss of information.

*The reworked table satisfies the first normal form.

Step 2: Second Normal Form 2NF

The second normal form in database normalization states that each row in
the database table must depend on the primary key.

The table splits into two tables to satisfy the normal form:
Section 1: Database Normalisation Page |6

The resulting database in the second normal form is currently two tables with no
partial dependencies.

Step 3: Third Normal Form 3NF

The third normal form decomposes any transitive functional dependencies.


Currently, the table Employee has a transitive dependency which decomposes
into two new tables:
Section 1: Database Normalisation Page |7

The database is currently in third normal form with three relations in total. At this
point, the database is normalized. Any further normalization steps depend on the
use case of the data.

BCNF (Boyce-Codd Normal Form)

A relation is in BCNF if and only if every determinant is a candidate key. It means

that each determinant in a BCNF relation has a unique value.


Section 1: Entity Relationship Diagram Page |8

Entity Relationship Diagram

ER Diagram, short for Entity Relationship Diagram, also known as ERD, is


a diagram that shows the relationships of a set of entities stored in a database.
In other words, ER diagrams help explain the logical structure of a database. ER
diagrams are built on three basic concepts: entities, attributes, and
relationships.

ER diagrams contain various symbols that use rectangles to represent


entities, ellipses to define attributes, and diamonds to represent relationships. At
first glance, ER diagrams look a lot like flowcharts. However, ER diagrams
contain many special symbols, the importance of which makes this model
unique.

Facts about ER Diagram Model:

 ER model allows you to draw Database Design.


 It is an easy to use graphical tool for modeling data.
 Widely used in Database Design.
 It is a GUI representation of the logical structure of a Database.
 It helps you to identify the entities which exist in a system and the
relationships between those entities.

Why use ER Diagrams?

1. Helps you to define terms related to entity relationship modeling.


2. Provide a preview of how all your tables should connect, what fields are
going to be on each table
3. Helps to describe entities, attributes, relationships.
4. ER diagrams are translatable into relational tables which allows you to
build databases quickly.
5. ER diagrams can be used by database designers as a blueprint for
implementing data in specific software applications.
Section 1: Entity Relationship Diagram Page |9

Example of a simple ER Diagram:

You might also like