包含类别、子类别和产品的数据库架构

发布于 2024-12-09 22:02:39 字数 408 浏览 1 评论 0原文

我正在寻找创建包含类别、子类别和产品的服装店数据库的最佳方法。

    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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音栖息无 2024-12-16 22:02:39

我建议如下构建您的类别表:

Category
----------
CategoryId
ParentCategoryId --nullable
CategoryName

我不确定您想要在产品中存储什么,所以我很难告诉您如何设计它,但至少您应该在其中有一个 CategoryId 列。我会将其留给您的业务逻辑来强制产品仅使用子类别(也称为类别表中具有 ParentCategoryId 的记录)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文