Lberteh Lberteh - 2 months ago 4
MySQL Question

mysql - correct approach to relate these tables

So, I have 2 tables

On the first table, lets call it products, lets say I have

product_id, company_id (this is a FK), product_name.

On the second table, lets call it deals, I have

deal_id, company_id (same one as the first table), deal_title.

I need to add products to the deals. if I added a product_id field to the deals table, I would have multiple rows and ids for each deal, which is completely wrong. What is the correct way to do it?


You should add a table for manage the relation between products and deals eg:

 table products_deal