我正在尝试创建一个数据库来存储汽车信息。
汽车可以分为新车,二手车或出租汽车。
每种类型的汽车都具有不同的属性,因为新车具有不需要使用的不同功能,并且二手车和租用车厢的情况相同。将来可以使用这三个类别的Application Admin侧窗体管理器来添加或删除属性。
目前,我将这些存储在1个产品表中,其中包含这3个类别所需的所有属性。
PRODUCT(id,title,description,model,kilometer,enginsize,conditions,.....,.,...)
由于建议通过管理员控制管理每个类别的表单,因此我正在寻找新的可伸缩数据库。
current development:
all common attributes in Products
PRODUCT(pid,title,description,...)
CATEGORY(cid,cname) new,used,rent
form_field(formfield_id,name,type) to store all attributes that are not common
form_field_category(formfield_id,cid) to store category associated attributes
form_post_data(post_id,pid,formfield_id,value) to store submitted data
有什么建议么。
最佳答案
您需要的称为Entity-Attribute-Value model。
如果表form_post_data
中的大多数值是文本,只需将其设置为varchar
字段即可。但是,如果要存储数值,选择和其他类型(可能要过滤的内容),请查看本文An alternative way of EAV modelling。
对于您具有可以具有多个值的属性,请参阅此后续文章EAV multi-value fields。
关于php - PHP的MySQL控制张贴表格领域,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13913642/