我第一次设计数据库表,我真的需要帮助来设计好的数据库表。
我对设计产品属性表完全感到困惑,但我确实请检查该设计并帮助我改进数据库结构。
product_categories
category_id
parent_category_id
category_title
category_slug
category_description
category_image
include_in_menu
display_mode
display_mode_content
category_status
attribute
attribute_id
category_id
attribute_title
attribute_slug
attribute_type
attribute_table
attribute_inputtype
attribute_label
is_required
is_unique
attribute_default_value
attribute_order
order_id
attribute_id
sort_order
attribute_value
attribute_value_id
attribute_id
value
product
product_id
product_categories_id
product_sku
product_title
product_slug
product_description
product_short_description
product_brand_id
product_warranty
product_images
product_price
product_selling_price
product_qty
product_height
product_weight
product_length
product_status
product_attribute
attribute_id
product_id
attribute_value
如果我需要更改我的表或字段名称,也请给出建议。如果我在数据库设计中有任何错误,请纠正我。
非常感谢你。
最佳答案
您将有很多表,例如:
Products:
ID
Name
Description
Etc...
Categories:
ID
Name
ProductCategories:
ProductID
CategoryID
Types:
ID
Name
ProductTypes:
ProductID
TypeID
您将有很多表,例如:
产品: ID 姓名 描述 等等...
类别: ID 姓名
产品类别: 产品ID 类别ID
类型: ID 姓名
产品类型: 产品ID 类型ID
这使您能够拥有多个类别和多种类型的产品...
根据下面的评论添加了更多示例。对于尺寸,您有一个尺寸表和一个将产品映射到尺寸的映射表...
Sizes:
ID
Name
ProductSizes:
ProductID
SizeID
如果您还需要考虑颜色,并且需要做出选择是存储具有颜色的尺寸还是具有尺寸的颜色...
Colours:
ID
Name
ProductColours
ProductID
ColourID
或者,如果您需要颜色和尺寸,或任何进一步的复杂性,我会直接将其抽象出来并使用 ProductAttributes 方式来实现,这可能超出了这个问题的范围,因为答案确实会很长。
但是采用与上面相同的样式,您可以有一个像这样的表格:
ProductSizesColours:
ProductID
SizeID
ColourID
关于mysql - 购物卡MYSQL数据库表设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34589520/