我是数据库设计的新手,我想确保我能把它做好。请看一下我数据库设计的一部分:
我的基本购物车数据库设计:
//table that holds shopping cart items that customer choose(not press checkout and order //them)
**shopping_cart**
{
id (int)
product_id (int) fk
product_quantity (int)
customer_user_id (int) fk
}
//table that holds product order data in time of checkout.(i hold them because supplier //can change after time products attributes value add some attributes or delete and change //the price of product)
**order**
{
id (int)
product_id (int) fk
customer_user_id (int) fk
}
//table that connect order to attribute table for products attributes value in the moment //of checkout
**order_attributes**
{
id (int)
order_id (int) fk
attribute_id (int) fk
}
//main product table
**product**
{
id (int)
sku (int)
product_name (varchar)
supplier_user_id (int) fk
}
//connection table many to many
**product_attributes**
{
id (int)
product_id (int) fk
attribute_id (int) fk
}
//table that holds products attributes (price, weight, color + new attributes that user //will create)
**attribute**
{
id (int)
product_id (int) fk
attribute_name (varchar)
attribute_value(varchar)
}谢谢你
发布于 2010-05-25 23:22:40
对我来说,这是一个糟糕设计,因为它使用属性表,而属性表是EAV表,这可能会导致性能问题。花点时间来定义你想要的产品属性,大多数产品都有相似的属性(颜色、大小、单位( 10个一包,单件等)。EAV是最后的手段。
在orderdetail表中存储价格等的详细信息。如果以后产品价格发生变化,您不希望价格发生变化。
我的结构将是类似的东西:订单订单My,日期,客户My订单详细信息order_id,Compnay_id,Product_id,part_number,product_name,数量,价格,单位,颜色,大小,其他属性订单说明order_id,备注
产品product_id、Part_number、product_name、Company_id、产品价格、颜色、大小、单位
当一些产品没有相同的属性时,最好有空列(除非你有成百上千的属性,通常情况下是不会有的)此外,如果你想要一个产品的完整规格,考虑把它们放在一个大的varchar文件中,并在上面放一个全文索引。这应该比EAV表的性能好得多。
发布于 2010-05-26 01:30:52
嗯,你可以从你的设计中删除两个表: order_attributes,product_attributes。否则,您的select查询将非常慢,必须连接这么多表。您可以将属性存储为order和product表中的列。
https://stackoverflow.com/questions/2903931
复制相似问题