the_boy_za
the_boy_za

Reputation: 287

How to create categories for products in ERD model?

I have designed an ERD for a website I am about to build.

This website has 2 groups: the USER and the COMPANY. Different companies (or shops, to be precise) have the option of logging into the site and enter new products into the system. The users can then log in and view products based on brands and categories.

In the ERD I have created all the tables, fields and one-to-many relations to the best of my knowlegde. I think that went well until the category tables.

I want the products to be categorized in like "MEN&SHOES", "KIDS&CLOTHES". I figured out I am going to need 2 tables for that: CategoryPersonGroup & CategoryProductGroup. But I do not know what is the right approach to link this to the products table. Please help! This is my ERD:

enter image description here

Upvotes: 0

Views: 4317

Answers (2)

Djordje Anatasovic
Djordje Anatasovic

Reputation: 23

You can use inheritance approach to this matter, i.e. make category table to store any values that are common to all the articles, and then make separate tables that will inherit category table, in which you can store your own values for that tables. And that's it, just link the main category table to persons and voila.

Upvotes: 0

suat
suat

Reputation: 4289

I think many to 1 relations between product and category tables would be convenient such as:
Product (N) -- has -- (1) CategoryProductGroup
Product (N) -- has -- (1) CategoryPersonGroup.

Upvotes: 1

Related Questions