我是数据库设计的新手。
cms的产品属性数据库设计有什么更好的选择?(请建议其他选项)。
选项1:1 table
products{
id
product_name
color
price
attribute_name1
attribute_value1
attribute_name2
attribute_value2
attribute_name3
attribute_value3
}
选项 2:3 table
products{
id
product_name
color
price
}
attribute{
id
name
value
}
products_attribute{
products_id
attribute_id
}
最佳答案
您在数据库设计中犯了一个常见错误,将名称存储在一列中,将值存储在另一列中。这不是关系数据库设计。
每个属性都应以列名命名。颜色、页面、衬衫尺寸、发布日期,应该是列名。
如果每种产品类型都有一组不同的属性,则还有其他解决方案。请参阅我对以下问题的回答:
另请阅读这个故事:Bad CaRMa: Introducing Vision在您实现围绕名称-值对设计的数据库之前。
关于relational-database - (数据库设计 - 产品属性): What is better option for product attribute database design?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2945045/