dsa45132 2009-10-02 20:01
浏览 10
已采纳

这个查找表示例如何工作?

Say I have a products table that stores off the shelf products that are not customizable and have static pricing. I also have 1 product in this same table that is customizable and it's price and all sorts of characteristics vary based on the configuration. The final price for this customizable product is based on an equation, not a sum of individual configuration options.

I understand I need a products table and a lookup table for each configuration attribute for this customizable product. But, I only want to store 1 item in the product table to identify this customizable product. I want the frontend to be able to just populate dropdown boxes based on the lookup table data (just a fetchAll and render all options).

My confusion is, how do I have a relation between this customized product in the product table and its children lookup tables. Do I have some column in the product table that says "this item needs lookup tables"? Very stumped on this.

Thanks in advance!

  • 写回答

1条回答 默认 最新

  • dongqing5575 2009-10-02 20:17
    关注

    There are a number of different ways to go about this as I am sure you already realize.

    I would suggest something to the idea of:

    Have a table for products. All basic product information directly related to that product would go in there.

    |productID|productName|productDescription|productPrice|....
    |INT      |Varcar     |Text              |Double      |....
    

    Create a table for configurations. This would be something to the effect of:

    |configID|configName|configDescription|configType|...
    |INT     |Varcar    |Text             |Enum      |...
    

    Then create a joining table

    |configID  |productID  |....
    |FK: config|FK: product|....
    

    The idea is that you create configurations then add them to the join. This allows existing products to get configurations, and to add and remove configurations as needed.

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

报告相同问题?

悬赏问题

  • ¥20 怎么在stm32门禁成品上增加记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 解riccati方程组