产品目录最具可扩展性的数据模型是什么?
每个产品都有一个父类别、一个类别和一个子类别。
如果产品表上有一个标准化的数据库,其中包含代表父类别、类别和子类别的整数,会更好吗?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好将类别表分开,并在产品表中包含 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.