Today, I got an introduction to data modeling and figured I should talk about it a bit. Some bits surprised me, and others made me realize how interconnected engineering and analytics really are.

Do I sound like Mufasa?

Anyway, what exactly is data modeling?

Data modeling is the process of defining how data is structured, how it relates to other data, and what rules govern it. This can be represented visually to help us understand how the different pieces of data connect.

Why Do We Need to Model Data?

The simplest answer: to answer business questions.

The more complex answer: it depends.

You don't start modeling the data until you understand the business case. Kind of like how you don't start cooking with your ingredients until you know what you want to make.

I mean, you could, but results may vary and be on the disgusting side.

Data modeling also helps build trust in your data, as you can establish rules within your model to maintain its integrity. Lastly, it helps enable what's next by creating a foundation for future analysis.

Understanding the Business

Data can come from just about anything. If you sell something, it might come from your POS system. If you work in marketing, it might come from surveys.

The question is: how can we use that data?

Let's say you work for an online store that serves millions of customers. You're a huge success!

But how do you continue that success?

You gain insights from your data. With millions of customers, however, you're going to have a lot of data coming from a lot of different places.

That's where data modeling comes in.

Let's continue with our scenario. You have sales, inventory, and marketing data.

How do these different datasets interact with one another? What information do you need to answer questions that will ensure the business's continued success? What customer information would benefit the marketing team, and how might their findings influence inventory decisions?

Understanding how these datasets relate to one another allows us to gain insights that might not be apparent when looking at them individually.

Asking the Right Questions

Let's shrink the scope a bit. You're now looking into your sales and inventory data.

What information do you need to determine whether you're ordering the right amount of inventory?

Before bringing these tables together, there are a few things to consider:

  • Do you need all the information from each table?
  • Are you okay with NULL values? Why or why not?
  • What does one row of data represent?
  • How do the records in one table relate to those in another?
  • What rules should the data follow?

Understanding what one row of data represents is known as understanding its granularity.

We also need to consider cardinality. Is the relationship between our tables one-to-one, one-to-many, or many-to-many?

For instance, one product can appear in many sales transactions. Understanding that relationship is important when bringing those tables together.

As you can see, there are a lot of things to consider before we even start building our model.

Establishing the Rules

Now that we have a better understanding of our data, let's establish how it should connect.

First, identify your primary keys. A primary key uniquely identifies each record within a table.

Next, identify your foreign keys. These allow us to establish relationships between tables by referencing keys in other tables.

What rules do you want to impose on your data?

Should every product have a ProductID? Should inventory quantities be allowed to fall below zero? Which fields should allow NULL values?

The answers to these questions depend on the business and its requirements. Establishing these rules helps maintain the integrity of our data and builds trust in the information we're using to make decisions.

Final Thoughts

What I found interesting about today's introduction to data modeling is how much of it happens before we even start building anything.

It's not just about connecting tables. It's about understanding the business, asking the right questions, and structuring the data in a way that allows us to answer those questions.

Going back to our cooking analogy, we now know what we want to make and what ingredients we need.

But how do we organize those ingredients?

Well, that's where normalization comes in, but I'll save that for another blog.