加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

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

发布时间:2020-12-12 08:46:25 所属栏目:MsSql教程 来源:网络整理
导读:我新的数据库设计. 什么是cms的产品属性数据库设计的更好选择?(请同时建议其他选项). 选项1:1表 products{idproduct_namecolorpriceattribute_name1attribute_value1attribute_name2attribute_value2attribute_name3attribute_value3} 选项2:3表 products{
我新的数据库设计.
什么是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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读