I am looking for the best way to create clothing store database that has categories, subcategories and products.
Categories: mens, womens, kids, home
subcategories: tops, bottoms, shoes, accessories, art
products: 10 different tops, 10 different bottoms, 10 different shoes, 10 different accessories and 10 different pieces of art for the home category.
I wand to display categories on first page, subcategories on second page and then products on the third page based on the selected categories and subcategories, just like a online store. products should only belong to one subcategory.
Thanks in advance.
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
)
精彩评论