包含类别、子类别和产品的数据库架构
我正在寻找创建包含类别、子类别和产品的服装店数据库的最佳方法。
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 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议如下构建您的类别表:
我不确定您想要在产品中存储什么,所以我很难告诉您如何设计它,但至少您应该在其中有一个 CategoryId 列。我会将其留给您的业务逻辑来强制产品仅使用子类别(也称为类别表中具有
ParentCategoryId
的记录)I would recommend structuring your category table like below:
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
)