产品目录最具可扩展性的数据模型是什么?

发布于 2024-11-24 16:07:48 字数 81 浏览 4 评论 0原文

每个产品都有一个父类别、一个类别和一个子类别。

如果产品表上有一个标准化的数据库,其中包含代表父类别、类别和子类别的整数,会更好吗?

Each product will have a parent category, a category, and a subcategory.

Would it be better to have a normalized database with integers representing parent category, category and subcategory on the product table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

成熟稳重的好男人 2024-12-01 16:07:48

最好将类别表分开,并在产品表中包含 id。否则,如果直接将类别信息存储在产品表中,最终会导致一致性和重复。

您始终可以在拉取产品时加入表,如果您担心加入,您还可以在应用程序端缓存类别表,并在从表中选择产品以了解其父项时查找类别哈希图和子类别信息。

Its better to have the category table separate and have ids in the product table. else you if you directly store category info in product table you will end up with consistency and duplication.

you can always join the table while pulling the products, if you are worried of joining you can also cache the categories table in the application side and do a lookup in to the category hash map while picking a product from the table to know about its parent and sub category info.

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