Reputation: 505
I'm creating an EER Diagram with MySQL Workbench.
What is the best way to implement a relationship between products, categories and companies tables?
I was thinking in this relation, but is this the best way considering I want to allow custommers of a company to manage their own products/categories? Isn't this a problem if I want to list only the categories of a company?
The second relation I designed is this one:
Which one is a good relation for my purpose? Or should I use an another one that can make it easier to manage only the products of a company or only the categories -> products of an company?
Upvotes: 0
Views: 9471
Reputation: 984
You should use the second one if every company should be able to have its own categories. Think about it if you would not have a company_id in your category. Then you would not be able to assign a category to a company. Also please declare your foreign keys like "category_id" and not "id_category". First one is better readable.
Upvotes: 2