关系数据库 – (数据库设计 – 产品属性):什么是更好的产品属性数据库设计选项?

前端之家收集整理的这篇文章主要介绍了关系数据库 – (数据库设计 – 产品属性):什么是更好的产品属性数据库设计选项?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我新的数据库设计.
什么是cms的产品属性数据库设计的更好选择?(请同时建议其他选项).

选项1:1表

  1. products{
  2. id
  3. product_name
  4. color
  5. price
  6. attribute_name1
  7. attribute_value1
  8. attribute_name2
  9. attribute_value2
  10. attribute_name3
  11. attribute_value3
  12. }

选项2:3表

  1. products{
  2. id
  3. product_name
  4. color
  5. price
  6. }
  7.  
  8. attribute{
  9. id
  10. name
  11. value
  12. }
  13.  
  14. products_attribute{
  15. products_id
  16. attribute_id
  17. }

谢谢,
优素福

解决方法

您在数据库设计中遇到一个常见的错误,将名称存储在一列中并将值存储在另一列中.这不是关系数据库设计.

每个属性都应以列名命名.颜色,页面,衬衫尺寸,发布日期,应为列名.

如果每个产品类型都有一组不同的属性,那么还有其他的解决方案.看到我的答案:

> Product table,many kinds of product,each product has many parameters详细.
> How do you model custom attributes of entities?
> Design question: Filterable attributes,SQL
> How to design a database schema to support tagging with categories?
> How to define structure in a tag-based organization?

在您实现围绕名称 – 值对设计的数据库之前,请阅读此故事:Bad CaRMa: Introducing Vision.

猜你在找的MsSQL相关文章