Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

DATA MODEL STRUCTURE

Hello!

 

I Created a data model for a report I'm building and I would like verify if it is the best way to structure it. 

 

Context: 

It all started with one table that had the following columns

 

customer_id

customer_name

customer_address

invoice_id

invoide_date

product_id

sales_value

supplier_id

supplier_type

supplier_name

 

My idea is to create a fact table with the sales information and dimension tables for customer, supplier, product and dates. 

 

When I started understanding the dataset, I noticed that the customer information was not as clean as I believed. The cases that exist are the following:

1. customer_id 123, you could have three names because that same id is associated to different customer site names, and sales would be each month asociated to each different name.  

2. customer_id 123 is associated to many names because it has changed names over the years, or they corrected a name e.g. The 'Hadware store LLC'corrected to 'Hardware Store LLC'.

3. Same with address, where you could have one customer_id with one name and several addresses for each customer site, or one address for different names

4. Some cases also for the names where, there are name changes but same addresses and viceversa.

 

Long story short, each customer id can have many names either sites, corrections to its name or both, and many addresses either sites or address corrections or both, and not every time a name changes, an address changes and viceversa.

 

The users of the report need both to be able to see the customer_id and the different historical names and the different historical addresses.

 

This is the model I created 

 

 

tbl_cliente (customer)  has customer_id(key) and customer_code

tbl_nombre (names)   has customer_id, customer_name (string) and name_id

tbl_direccion (address) has customer_ud, customer_address (string) and address_id

tbl_ventas (sales) has amongst others, address_id, name_id, invoice_number,sales_value, date, etc...

 

My idea is that creating a relation**bleep** in the way the picture shows, I could both by name or by address identigy the historical use of both.

 

Some sampe calculations i've created work well with a small data extract, but my dataset will have around 80 million rows and I'm not sure if this structure could be something not good for performance once is fully implemented

 

What I would really appreciate is you feedback on the data model structure and, if you know of a better way of creating it, I would really appreciate it.

 

Thank you very much in advance!!

 

No Replies