如何存储销售?
您将如何进行商店销售?
我想存储一个包含订购产品的序列化数组与一个带有引用订购产品的外键的 sale_product 表。
您对此有何想法?有其中之一的经验吗?
泰
How would you store sales ?
I though about storing a serialized array which contains the products ordered vs a sale_product table with a foreign key referencing products ordered.
What are you thoughts about this ? Any experience with one of these ?
Ty
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于您想要优化的内容。如果您想要灵活性和执行复杂查询的能力,则 sale_product 表是更好的选择。另一种方法可能适用于一种类型的查询的性能非常重要的一些场景。
如果你刚刚开始,我会首先考虑标准化设计,因为我会考虑其他设计的过早优化。在设计数据库模型时,我喜欢考虑数据库需要支持什么样的操作(前端和报告),然后设计模型。
It depends on what you are trying to optimize. A sale_product table is a much better way to go if you want flexibility and ability to do complex queries. The other way could be suitable for a few scenarios where performance of one type of query is really important.
If you are just starting, I would consider a normalized design first, because I would consider the other design premature optimization. When designing a database model, I like to think of what kind of operations the database will need to support (both frontend and reporting), and then design the model.
销售不一定与订单相同。
如果产品意外无法交付、付款被退回等,订单可能不会导致销售。
Sales are not necessarily identical to Orders.
An order may not result in a sale if the product can unexpectedly not be delivered, if payment bounces, etc.