dorflv5944 2018-08-24 15:34
浏览 64
已采纳

如果我要在数据库中存储两条记录,则需要测量单位表

In my e-commerce application there are several products available in two units i.e. product "X" has two types of packaging

  1. 200 gram
  2. 400 gram

Is there any need for creating Unit_Of_Mesurement table? If not then what is the solution or is there any other solution?

  • 写回答

1条回答 默认 最新

  • dsfdsfds521521 2018-08-24 18:06
    关注

    For an e-commerce site where a given product may be sold in different packages, you can either have each product package stored as a separate product, or use a second table to store the different formats of the product, where the rest of the generic product info is taken from a main product table.

    For example, you'd have a product table, that contains information that applies to the product regardless of which format is being considered:

    ID | name      | brand
    --------------------------
     1 | Product 1 | ACME Corp
     2 | product 2 | ACME Corp
    

    And then you'd have a product_format table, which contains the different packaging variations that product might have. If a product isn't sold in any different formats, then you could just have a single row here that contains the price, without specifying the format, since you won't need to show that information.

    ID | product_ID | format | price
    ----------------------------------
     1 | 1          | 200g   | 19.99
     2 | 1          | 400g   | 37.99
     3 | 2          | null   | 8.99
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路