douershuang7356 2013-11-27 22:08
浏览 89
已采纳

db中的购物车 - 订单行表或单独的购物车表?

I want to store the cart data of my multitenant app in the database.

I am wondering if it would be better to have a separate table (a project I work on does it that way but I think they migrated from sessions to that solution) or if I should put everything in the order lines table and have an order status to decide if its part of a cart or an order.

What would be the pros and cons for each solution?

  • 写回答

1条回答 默认 最新

  • dsxgby126001 2013-11-27 22:27
    关注

    If, within your system, the data related to the cart are exactly the same as the order line and only differ by a status, then you could keep all in the same table and differentiate by the value of the foreign key to a status table.

    However the properties related to placed orders and products of a cart usually differ. The cart related data basically hold a state for a user to resume her activities and possibly present products that are likely to be consumed (a bit unusual). On the other hand data related to order lines are important, they are connected with transactions, financial info, stock, history,trends etc, this is the data that actually matters.

    So the placed orders are the data with value, that get analysed and processed, while the cart is only stored for user's convenience. Generally it is best to keep them separated for flexibility and scalability.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题