Normalized vs. Denormalized

Data Structures

Posted by Nolan Hughes on December 3rd, 2018

A database is just an organized way to store your data. The design of that database is largely based off of your current needs and what you think your needs will be in the future. I had previously done some research regarding best practices and through my projects I've been exposed to a few different ways to structure my data.

With that said, I hadn't heard of the terms normalized and denormalized data structures until recently, so I figured I needed to do some research. It's an incredibly fascinating topic and I'll lay out my finding on the differences and use cases with some examples below.

Denormalized

A data structure in its simplest form would look like this.

Name Age Hobbies
Jill 45 Golf, Music, TV
Eve 60 Music
John 25 Soccer, TV

Here we have aboslutely eveyrthing in one table. This works and makes all of our data easy to access, but it's vulnerable to data duplication and non standardized ways of labeling the same data. As it stands right now, everything is easy to read, but what happens when we start to include more information about these people. It is much better suited for multiple tables. To fix this we need normalization.

Normalized

A normalized database eliminates redundancy and helps organize our data. A good overarching rule for normalization is that each table full of table only has information about itself. So in our example above we would need a person table and a hobbies table. Adding an id to each row is also good practice and will help us later.

id Name Age
1 Jill 45
2 Eve 60
3 John 25
id Hobby
1 Music
2 TV
3 Golf

Isn't that better! Now all we have to do is link them together and we have a simple, normalized database.