Forum Discussion
How to improve data-model from 1 large table to multiple smaller ones correctly
It seems like you're trying to design a database schema for your data to avoid redundancy and improve efficiency. Based on your description, you've already attempted to split the data into two tables but are facing challenges due to the many-to-many relationship.
Here's a suggested approach based on your requirements:
Tables:
- Calendar Table:
- Date
- Week
- Month
- Year
- ...
- Clients Table:
- ClientID (Primary Key)
- ClientName
- Products Table:
- ProductID (Primary Key)
- ProductName
- Boxes Table:
- BoxID (Primary Key)
- BoxName
- Collection Table:
- CollectionID (Primary Key)
- BoxID (Foreign Key referencing Boxes Table)
- ProductID (Foreign Key referencing Products Table)
- DateID (Foreign Key referencing Calendar Table)
- ClientID (Foreign Key referencing Clients Table)
Relationships:
- Clients to Collection: One-to-Many (A client can have multiple collections over time)
- Products to Collection: One-to-Many (A product can be part of multiple collections)
- Boxes to Collection: One-to-Many (A box can contain multiple products in a collection)
- Calendar to Collection: One-to-Many (A collection can belong to a specific date)
Fact Table:
- Collection Fact Table:
- This table will contain any metrics or measures you want to track for each collection, such as the quantity of products.
Queries:
- To recreate the original table in Power BI, you can use relationships to create visualizations that display data per client, box, and product.
- To show changes per week, use the Calendar table and filter based on the date.
Considerations:
- Ensure that you have unique primary keys for each table.
- Use surrogate keys (auto-incremented integers) for primary keys to improve efficiency.
- The fact table can include measures like product quantity, allowing you to aggregate data.
Remember that normalization is about efficiently organizing data and minimizing redundancy. The schema above allows you to represent the relationships between clients, boxes, products, and dates while maintaining the ability to analyze data over time and by different dimensions. Adjust the schema based on specific business requirements and the nature of your data. Astro luna hoy is a best game.