Mysql 鞋类网上商店数据库规范化
更新 这是我当前的数据库图,用于销售在线鞋Mysql 鞋类网上商店数据库规范化,mysql,database,database-design,normalization,database-normalization,Mysql,Database,Database Design,Normalization,Database Normalization,更新 这是我当前的数据库图,用于销售在线鞋 将有不同类别的鞋(高跟鞋、坡跟鞋、凉鞋、高跟鞋折扣等) 每双鞋都有不同的颜色,不同的尺寸。对于每种颜色和尺寸 它将有不同的库存,可能有不同的订单类型(现成库存/预订单) 对于每种尺寸和颜色,可能会有不同的价格 每一双不同尺寸和颜色的鞋子,它们(可能)会有不同的形象,而不是普通的 我做得对吗?我应该做些什么来改进这个数据库?我真的非常感谢任何反馈/意见/批评 结束更新 im是数据库设计的新手,与在线商店(MySQL数据库)的数据库设计相混淆 比如说
- 将有不同类别的鞋(高跟鞋、坡跟鞋、凉鞋、高跟鞋折扣等)
- 每双鞋都有不同的颜色,不同的尺寸。对于每种颜色和尺寸
- 它将有不同的库存,可能有不同的订单类型(现成库存/预订单)
- 对于每种尺寸和颜色,可能会有不同的价格
- 每一双不同尺寸和颜色的鞋子,它们(可能)会有不同的形象,而不是普通的
id
name
category_id
details
image
id
color
id
size
size_details
id
generic_shoes_id //references to generic_shoes
name // if the owner wants to make another name, if not then use generic_shoes' name
order_type //ready stock or pre order
id
color_id
specific_shoes_id
id
size_id
specific_shoes_id
id //will be used in the orders table
colors_shoes_id //reference to pivot colors_shoes
sizes_shoes_id //reference to pivot sizes_shoes
specific_shoes_id //reference to specific_shoes
stock //each color and size will have diff stock
price //each color and size maybe will have diff price
weight //each size will have different weight
颜色
id
name
category_id
details
image
id
color
id
size
size_details
id
generic_shoes_id //references to generic_shoes
name // if the owner wants to make another name, if not then use generic_shoes' name
order_type //ready stock or pre order
id
color_id
specific_shoes_id
id
size_id
specific_shoes_id
id //will be used in the orders table
colors_shoes_id //reference to pivot colors_shoes
sizes_shoes_id //reference to pivot sizes_shoes
specific_shoes_id //reference to specific_shoes
stock //each color and size will have diff stock
price //each color and size maybe will have diff price
weight //each size will have different weight
尺寸
id
name
category_id
details
image
id
color
id
size
size_details
id
generic_shoes_id //references to generic_shoes
name // if the owner wants to make another name, if not then use generic_shoes' name
order_type //ready stock or pre order
id
color_id
specific_shoes_id
id
size_id
specific_shoes_id
id //will be used in the orders table
colors_shoes_id //reference to pivot colors_shoes
sizes_shoes_id //reference to pivot sizes_shoes
specific_shoes_id //reference to specific_shoes
stock //each color and size will have diff stock
price //each color and size maybe will have diff price
weight //each size will have different weight
特定鞋款
id
name
category_id
details
image
id
color
id
size
size_details
id
generic_shoes_id //references to generic_shoes
name // if the owner wants to make another name, if not then use generic_shoes' name
order_type //ready stock or pre order
id
color_id
specific_shoes_id
id
size_id
specific_shoes_id
id //will be used in the orders table
colors_shoes_id //reference to pivot colors_shoes
sizes_shoes_id //reference to pivot sizes_shoes
specific_shoes_id //reference to specific_shoes
stock //each color and size will have diff stock
price //each color and size maybe will have diff price
weight //each size will have different weight
然后,我提出了pivot颜色和尺寸的鞋,这些鞋具有多对多关系:
特定颜色的鞋子
id
name
category_id
details
image
id
color
id
size
size_details
id
generic_shoes_id //references to generic_shoes
name // if the owner wants to make another name, if not then use generic_shoes' name
order_type //ready stock or pre order
id
color_id
specific_shoes_id
id
size_id
specific_shoes_id
id //will be used in the orders table
colors_shoes_id //reference to pivot colors_shoes
sizes_shoes_id //reference to pivot sizes_shoes
specific_shoes_id //reference to specific_shoes
stock //each color and size will have diff stock
price //each color and size maybe will have diff price
weight //each size will have different weight
特定尺码的鞋子
id
name
category_id
details
image
id
color
id
size
size_details
id
generic_shoes_id //references to generic_shoes
name // if the owner wants to make another name, if not then use generic_shoes' name
order_type //ready stock or pre order
id
color_id
specific_shoes_id
id
size_id
specific_shoes_id
id //will be used in the orders table
colors_shoes_id //reference to pivot colors_shoes
sizes_shoes_id //reference to pivot sizes_shoes
specific_shoes_id //reference to specific_shoes
stock //each color and size will have diff stock
price //each color and size maybe will have diff price
weight //each size will have different weight
然后我想不同的颜色和尺寸会有不同的库存,也许价格会不同,所以我想:
鞋\产品\细节
id
name
category_id
details
image
id
color
id
size
size_details
id
generic_shoes_id //references to generic_shoes
name // if the owner wants to make another name, if not then use generic_shoes' name
order_type //ready stock or pre order
id
color_id
specific_shoes_id
id
size_id
specific_shoes_id
id //will be used in the orders table
colors_shoes_id //reference to pivot colors_shoes
sizes_shoes_id //reference to pivot sizes_shoes
specific_shoes_id //reference to specific_shoes
stock //each color and size will have diff stock
price //each color and size maybe will have diff price
weight //each size will have different weight
我觉得这些桌子可以,但是我在想,我应该用这张桌子来代替吗
删除:
id //will be used in the orders table
color_id //reference to colors table
size_id //reference to sizes table
specific_shoes_id //reference to specific_shoes
stock //each color and size will have diff stock
price //each color and size maybe will have diff price
weight //each size will have different weight
我认为问题在于,对于最后一个表is->foreign key cascade,如果颜色/大小被删除,那么它也会删除特定的\u shoes\u details行
谁能给我更好的方法?因为我不知道我应该使用哪种方法,第一种是带有颜色和大小透视表的方法,还是最后一种
谢谢
我非常感谢您提供的任何帮助/反馈我认为您在数据库设计方面做得很好 我会和你的最后一个一起去。您几乎不可能想要删除颜色或尺寸。你不再穿18号的衣服做生意了 删除的更好选项是将颜色设置为非活动。添加一个活动列,以便可以将其关闭,但仍保留库存 我还将为特定的鞋子添加说明和/或图像
我相信您也可以选择不在删除时层叠,如果这是您所关心的。我认为您在数据库设计方面做得很好 我会和你的最后一个一起去。您几乎不可能想要删除颜色或尺寸。你不再穿18号的衣服做生意了 删除的更好选项是将颜色设置为非活动。添加一个活动列,以便可以将其关闭,但仍保留库存 我还将为特定的鞋子添加说明和/或图像
我相信你也可以选择不在删除时层叠,如果这是你所关心的。从对问题的描述中,我感到有些复杂,我无法理解。我会想到,您应该能够删除特定的表 这是我建议您考虑的模式
我相信这个模式的好处是它更简单,而且尽我所能,它提供了与您建议的标准化相同的标准化级别。从对问题的描述中,我感到有一些我无法理解的复杂性。我会想到,您应该能够删除特定的表 这是我建议您考虑的模式