How to design a product table for many kinds of product where each product has many parameters

后端 未结 4 2009
故里飘歌
故里飘歌 2020-11-22 01:08

I do not have much experience in table design. My goal is to create one or more product tables that meet the requirements below:

  • Support many kinds of produ

4条回答
  •  -上瘾入骨i
    2020-11-22 02:05

    You can have a Product table and a separate ProductAdditionInfo table with 3 columns: product ID, additional info name, additional info value. If color is used by many but not all kinds of Products you could have it be a nullable column in the Product table, or just put it in ProductAdditionalInfo.

    This approach is not a traditional technique for a relational database, but I have seen it used a lot in practice. It can be flexible and have good performance.

    Steve Yegge calls this the Properties pattern and wrote a long post about using it.

提交回复
热议问题