I would recommend structuring your category table like below:
Category
----------
CategoryId
ParentCategoryId --nullable
CategoryName
I’m not sure what you want to store in products so it’s hard for me to tell you how to design that, but at a minimum you should have a CategoryId column in there. I would leave it to your business logic to force products to only use SubCategories (aka records from the Category table that have a ParentCategoryId
)
1
solved Database schema with categories, subcategories and products [closed]