开发者

Database schema with categories, subcategories and products [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that i开发者_运维问答s not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜