dongtuojuan8998 2014-08-06 18:20
浏览 14

管理数据库中多种类型产品的付款

I have multiple type of digital goods that can be bought from site.(Passes and tickets).

I want some suggestions regarding what should be the database structure of such payments .Table used for storing payments is purchase history

OPTION 1

1st option can be as shown below in which item id of each product will be in seperate column. For each payment only that column of that product is populated which is purchased .enter image description here

OPTION 2 In second option Id of product will be store in 1 column and type of product in other.enter image description here

Please suggest which option is better or can there be any other method which is better and efficient than these ?

  • 写回答

1条回答 默认 最新

  • dragon19720808 2014-08-07 03:59
    关注

    Option 2 is scale-able, option 1 isn't.

    If you went with option 1, then decided to add a dozen more types of products, you'll need a new table for each, a new column in purchase_history for each, and to rewrite most of your queries and reports to suit.

    Option 2 allows you not to worry about this, even if you stick with just the two types of products forever - at least you've only got one column to deal with in your purchase history table.


    If it were me, I'd be combining the tickets and passes tables into a "products" table, and have an ENUM or similar field to differentiate them. Sure, the tickets table has more fields which passes doesn't need - but passes doesn't have any that tickets doesn't need, and you can just make the extras nullable and leave them there. Then just use product_id in your purchase history and do away with the product type table and field completely.

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP