Home  >  Article  >  Backend Development  >  一个关于报价怎么存储的有关问题

一个关于报价怎么存储的有关问题

WBOY
WBOYOriginal
2016-06-13 13:35:37769browse

一个关于报价如何存储的问题
自己学写第一个php程序 有个地方不知道怎么设计数据库,如图:



报价信息是动态增加的,每增加一个报价,就要添加1个价格、1个数量、1个备注、不可能每个字段都在数据库里设置独立字段,应该是用什么方式存在1个数据库字段里,用的时候再按格式提取出来,但不知道实现的思路!

这个在数据库里怎么存储会好一点?还要便于以后提取报价进行报价高低比较。




------解决方案--------------------
图挂了,传csdn再贴图吧
为什么不可能把 价格、数量、备注 放在三个独立字段?
要存储在一个字段里 可以序列化或者处理成json存入,取出来的时候再处理成相应的数组
------解决方案--------------------
id INT(8) UNSIGNED NOT NULL AUTO_INCREMENT, 
products_id(8) not null, 
price varchar(10) not null, 
quality int(7) not null, 
text varchar(255) not null, 

id | products_id | price | quality | text

1 | 1 | 15.00 | 25 | 备注
2 | 1 | 15.60 | 30 | 备注
...


select * from table where products_id='1' order by id limit 1. 取出最近更新的,产品编号1的。
select * from table where products_id='1' 取出所有产品编号1的
------解决方案--------------------
key=>value
------解决方案--------------------
这样子可以用序列化数组的方式存储,需要的时候取出来还原数组即可
serialize()

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn