更新
这是我当前的数据库图,用于销售的在线鞋
- 将有不同类别的鞋子(高跟鞋、坡跟鞋、凉鞋、高跟鞋折扣等)
- 每双鞋会有不同的颜色,不同的尺码。对于每种颜色和尺寸,
- 它会有不同的库存,可能有不同的订单类型(现货/预购)
- 对于每种尺寸和颜色,可能会有不同的价格
- 而且每双鞋的尺码和颜色都不同,它们(也许)会有不同的形象,而不是普通的
我做得对吗?我应该怎么做才能改进这个数据库?我真的很感谢任何反馈/意见/批评
结束更新
我是数据库设计的新手,对网上商店的数据库设计感到困惑(MySQL 数据库)
假设网上商店会出售不同颜色、尺码、不同库存和价格的鞋子,每种颜色和尺码。
我想出了这些表:
generic_shoes
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
然后我想出了带有多对多rel的枢轴colors_shoes和sizes_shoes: colors_specific_shoes
id
color_id
specific_shoes_id
size_specific_shoes
id
size_id
specific_shoes_id
然后我认为不同的颜色和尺寸会有不同的库存和不同的价格,所以我想出了:
shoes_product_details
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
我认为这些桌子会很好,但后来我想,我应该用这张桌子代替吗?
删除:
- size_specific_shoes
- color_specific_shoes
并且只需使用 specific_shoes_details 表中的颜色 ID 和尺寸 ID:(在下表中,我只是直接参考颜色和尺寸表)
specific_product_details 表
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
我认为问题在于最后一个表是 -> 外键级联,如果删除了颜色/大小,那么它也会删除 specific_shoes_details 行。
谁能给我更好的方法?因为我不知道我应该使用哪种方法,第一个带有颜色和大小数据透视表的方法还是最后一个..
谢谢
我非常感谢任何帮助/反馈