In the requirements given to me, multiple products can be assigned to a single sale. However, I need help how this can be done in SQL and how would the table look like. Below is what my schema looks like:
In the sales fact, I also included a column containing the aggregate sales for all the product included in the sale.
Ps. Same case with the Products but with Official_Receipt_Id as a single sale can also have many Official_Receipt_Id.
Help will be highly appreciated.
The proper way to do this is to use multiple tables and JOIN them in your queries.
For example:
The sales_product table contains one row for each product a sale is associated with and effectively links the product and sales tables together. It would look something like this.
When you want to retrieve a sale and all of the products you can do something like this: