我新的数据库设计.
什么是cms的产品属性数据库设计的更好选择?(请同时建议其他选项).
什么是cms的产品属性数据库设计的更好选择?(请同时建议其他选项).
选项1:1表
- products{
- id
- product_name
- color
- price
- attribute_name1
- attribute_value1
- attribute_name2
- attribute_value2
- attribute_name3
- attribute_value3
- }
选项2:3表
- products{
- id
- product_name
- color
- price
- }
- attribute{
- id
- name
- value
- }
- products_attribute{
- products_id
- attribute_id
- }
谢谢,
优素福
解决方法
您在数据库设计中遇到一个常见的错误,将名称存储在一列中并将值存储在另一列中.这不是关系数据库设计.
每个属性都应以列名命名.颜色,页面,衬衫尺寸,发布日期,应为列名.
如果每个产品类型都有一组不同的属性,那么还有其他的解决方案.看到我的答案:
> 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.