Example:
category : food, bike, car
Items under the category:
food = {rice, fish, beef};
bike = {Honda, Suzuki};
car = {Honda, Toyota, BMW};
here, the categories "bike" and "car" may contain the same items as the "Honda". But no category can contain the same elements.
Table Name (Column Name):
1. category
-> id (primary, auto increment)
-> category_name (char, unique)
2. items
-> id (primary, auto increment)
-> item_name (char)
3. category_item_relation (many to many relation between table 1 and 2)
-> category_id (foreign key)
-> item_id (foreign key)
where it item_idwill be unique with the same category_id, you need to know the procedure in MySql.
source
share