Not quite sure that title explains it..
Here my problem. I have an table that represents products. These products are part of a monthly subscription that come grouped in a box. At checkout some of the products can also be added in individually to the order as "addons". Example, subscription A comes with a box with products 1,2,3,3 in it but you can add as many extra 3 and 4 as you like since they are also addons.
My solutions for representing this data is to have a products
table and then a products_addons
table that just stores the id of the product. See the layout below.
products
id, name, price
products_addons
product_id
This way I can join the tables and see which product is also an addon, so in
my example products with id 3 and 4 would be saved into the product_addons
table. This seems very inefficient and I'm wondering if there is a better way
to go about this? I was thinking about a bool field in the products
table is_also_addon
but this also seems inefficient.
Here is a quick take to ponder, as well as my write-up on Junction Tables in that link.
It would give you great flexibility in having month-over-month tweaks to your packages (or assemblies) of the month with new assemblies created. And allowing for re-use of old ones you want to promote as oh so special again with minimal effort.
Pricing history is maintained.
Allows the user to put whatever they want in the shopping cart.
I am sure sure the assemblies would need a visual for some people seeing this. I could put a few examples together.
The main takeaways are the use of Junction tables, and ordering out of on products table.