Mysql 鞋类网上商店数据库规范化

Mysql 鞋类网上商店数据库规范化,mysql,database,database-design,normalization,database-normalization,Mysql,Database,Database Design,Normalization,Database Normalization,更新 这是我当前的数据库图,用于销售在线鞋 将有不同类别的鞋(高跟鞋、坡跟鞋、凉鞋、高跟鞋折扣等) 每双鞋都有不同的颜色,不同的尺寸。对于每种颜色和尺寸 它将有不同的库存,可能有不同的订单类型(现成库存/预订单) 对于每种尺寸和颜色,可能会有不同的价格 每一双不同尺寸和颜色的鞋子,它们(可能)会有不同的形象,而不是普通的 我做得对吗?我应该做些什么来改进这个数据库?我真的非常感谢任何反馈/意见/批评 结束更新 im是数据库设计的新手,与在线商店(MySQL数据库)的数据库设计相混淆 比如说

更新

这是我当前的数据库图,用于销售在线鞋

  • 将有不同类别的鞋(高跟鞋、坡跟鞋、凉鞋、高跟鞋折扣等)
  • 每双鞋都有不同的颜色,不同的尺寸。对于每种颜色和尺寸
  • 它将有不同的库存,可能有不同的订单类型(现成库存/预订单)
  • 对于每种尺寸和颜色,可能会有不同的价格
  • 每一双不同尺寸和颜色的鞋子,它们(可能)会有不同的形象,而不是普通的

我做得对吗?我应该做些什么来改进这个数据库?我真的非常感谢任何反馈/意见/批评

结束更新

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和尺码id即可: (在下表中,我只是直接参考颜色和尺寸表)

    特定产品详细信息表

    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号的衣服做生意了

    删除的更好选项是将颜色设置为非活动。添加一个活动列,以便可以将其关闭,但仍保留库存

    我还将为特定的鞋子添加说明和/或图像


    我相信你也可以选择不在删除时层叠,如果这是你所关心的。

    从对问题的描述中,我感到有些复杂,我无法理解。我会想到,您应该能够删除特定的表

    这是我建议您考虑的模式

  • 颜色(颜色id、颜色名称、活动等)
  • 大小(大小标识、大小名称、大小描述、活动等)
  • 类别(类别id、类别名称、活动等)
  • 图像(图像id、图像路径、活动等)
  • 订单模式(模式id、模式名称、模式描述等)
  • 鞋(鞋号、颜色、尺码、类别、图像、款式、库存、价格、重量等)
  • 如果您的尺码也需要国家/地区编码,则可以提供其他级别的详细信息。在这种情况下,请考虑

  • 大小(大小标识、大小名称、国家标识、大小描述、活动等)
  • 国家(国家/地区id、国家/地区名称、活动等)
  • 请注意,我在所有表上都留下了一个活动标志,以便您可以使用它来指示特定的引用元素未被使用,并且您可以使用它来级联到表中


    我相信这个模式的好处是它更简单,而且尽我所能,它提供了与您建议的标准化相同的标准化级别。

    从对问题的描述中,我感到有一些我无法理解的复杂性。我会想到,您应该能够删除特定的表

    这是我建议您考虑的模式

  • 颜色(颜色id、颜色名称、活动等)
  • 大小(大小标识、大小名称、大小描述、活动等)
  • 类别(类别id、类别名称、活动等)
  • 图像(图像id、图像路径、活动等)
  • 订单模式(模式id、模式名称、模式描述等)
  • 鞋(鞋号、颜色、尺码、类别、图像、款式、库存、价格、重量等)
  • 如果您的尺码也需要国家/地区编码,则可以提供其他级别的详细信息。在这种情况下,请考虑

  • 大小(大小标识、大小名称、国家标识、大小描述、活动等)
  • 国家(国家/地区id、国家/地区名称、活动等)
  • 请注意,我在所有表上都留下了一个活动标志,以便您可以使用它来指示特定的引用元素未被使用,并且您可以使用它来级联到表中

    我相信这个模式的好处是它更简单,而且尽我所能,它提供了与您建议的标准化相同的标准化级别。

    哦,好的,“删除将是