In my previous blog, I spoke a bit about data modeling, why we need it, and some of the things we should consider before building our models.

Now that we know what we want to cook and what ingredients we need, let's talk about how we organize those ingredients.

Enter data normalization.

What Is Data Normalization?

Data normalization is the process of organizing data into structured tables to reduce unnecessary redundancy, establish logical dependencies, and prevent inconsistencies when inserting, updating, or deleting data.

Let's go back to our successful online store from the previous blog.

You have millions of customers making purchases, some of whom are returning customers. Imagine storing their name, email address, and other customer information every single time they make a purchase.

That's a lot of repeated information!

Now imagine that one of those customers changes their email address. Instead of updating that information in one place, you might have to update it across multiple records.

What happens if you miss one?

You now have conflicting information about the same customer.

This is an example of an update anomaly, and it's one of the problems normalization helps address.

There are levels to this one, so let's take a look at the first three.

1NF — First Normal Form

First Normal Form requires each field to contain a single value rather than a list of values or repeating groups. We should also be able to uniquely identify each record.

Let's say a customer purchases three different products, and we store all three ProductIDs in a single field.

How would we easily calculate how many times a particular product was purchased?

Instead, we can separate those products into individual rows.

Before

After

We've now made our data easier to work with, but we still have some work to do.

2NF — Second Normal Form

Second Normal Form requires our data to meet the requirements of 1NF. Additionally, every non-key attribute must depend on the entire candidate key, not just part of it.

Let's say our sales table uses a combination of OrderID and ProductID to uniquely identify each row.

The quantity purchased depends on both the order and the product. However, the product name only depends on the ProductID.

So why are we storing the product name in every sales record?

We can move that information into a separate Products table and use ProductID to connect the two tables.

We've now reduced some of that unnecessary repetition.

3NF — Third Normal Form

Third Normal Form takes things a step further.

Our data must already meet the requirements of 2NF, and we want to remove what are known as transitive dependencies.

Sounds complicated, right?

Let's say our Orders table contains an OrderID, CustomerID, CustomerName, and CustomerEmail.

The customer's name and email depend on the CustomerID, rather than directly on the OrderID.

We can move that information into a separate Customers table and use CustomerID to establish the relationship between our tables.

Now, if a customer changes their email address, we only need to update it in one place.

Pretty cool, right?

Why Does All of This Matter?

Normalization helps us reduce unnecessary redundancy, maintain data integrity, and potentially reduce the amount of storage needed for our data.

It also makes maintaining and updating our data easier.

Does that mean a fully normalized model is always the best approach?

Well, going back to something I said in my previous blog: it depends.

While normalization is beneficial for many transactional systems, analytical models sometimes intentionally introduce redundancy to simplify queries and improve reporting performance.

It all comes back to understanding what the business needs and how the data will be used.

Final Thoughts

What I find interesting about normalization is that it isn't just about organizing data to make it look cleaner. It's about being intentional with where information lives and how it relates to other information.

We've only covered the first three normal forms, and yes, there is a fourth!

But much like my journey with SQL, I think I'll get comfortable with what I've learned so far before getting too far ahead of myself.

One step at a time!