开发者

How do you store sales?

How would you store sales ?

I though ab开发者_运维技巧out 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜