5 Denormalization
5 Denormalization
DENORMALIZATION OF
DATABASE TABLES
1
5
WHAT IS DENORMALIZATION??
Denormalization is a strategy that
database managers use to increase the
performance of a database
infrastructure.
It involves adding redundant data to a
normalized database to reduce certain
types of problems with database
queries that combine data from various
tables into a single table.
3
5
NORMALIZATION – Example
4
5
NORMALIZATION – Example
5
5
DENORMALIZATION – Example
6
5
7
5
8
5
Why Denormalization is Done
• As a thumb rule of database design, we should
have normalized data so that there should not
be any redundancy. But this normalization
increases the cost of performance.
• Comparing the good design and performance
of database, performance takes the priority.
• Any user accessing the database is more
interested in quick and correct result than how
a database is designed.
9
5
How to Denormalize a Database??
• Denormalization disregards the rules of
normalization it will absolutely lead to
redundant data and duplicated columns.
• Denormalization means joining data from two
or more normalized tables this data can then
be inserted into a single table. this is often
referred to as flattening
• The flatten data will usually be redundant
data
10
5
Why would you ever create
redundant data??
• With denormalization there is a trade-off between
data being flattened and performance
Normalized data can take less space and increase
performance
• However it will require data to be joined
• Joins across tables needs significantly more
overhead within a Database server
“ The More joins involved in a query the more
resources will be needed to retrieve the data “
11
5
Example
• Let’s take an example of Grocery store..
• You want to buy ingredients for three meals of
the day.
12
5
Example
• Data Retrieval in Normalized Situation
Normalization vs Denormalization
15
5
How to balance tradeoff between
Normalization & Denormalization
One way to balance this trade-off is to look for
the best of both worlds
• it may make sense to store your data in both
normalized relational tables and in
denormalized flatten table
16
5
How to balance tradeoff between
Normalization & Denormalization
Let’s take example of Movie Rental Store
We might consider keeping two versions of the
data
• Normalized relational tables to complete
transactions
• A separate flattened version for reporting
17
5
How to balance tradeoff between
Normalization & Denormalization
18
5
How to balance tradeoff between
Normalization & Denormalization
19