A question about how a quote is stored

Source: Internet
Author: User
A question about how quotes are stored
Learn to write your first PHP program there's a place where you don't know how to design a database,



Quotation information is dynamically increased, each increase of a quote, will add 1 price, a quantity, a note, it is not possible to each field in the database set up a separate field, should be in what way exist 1 database fields, use the time and then extract the format, but do not know the idea of implementation!

How can this be better stored in the database? Also to facilitate the subsequent extraction of quotations for the high and low comparison.




------Solution--------------------
Picture hangs, pass csdn again map
Why is it impossible to put prices, quantities, notes in three separate fields?
To be stored in a field can be serialized or processed into JSON to deposit, take out the time to process the corresponding array
------Solution--------------------
ID INT (8) UNSIGNED not NULL auto_increment,
PRODUCTS_ID (8) NOT NULL,
Price varchar (TEN) is not NULL,
Quality INT (7) is not NULL,
Text varchar (255) is not NULL,

ID | products_id | Price | Quality | Text

1 | 1 | 15.00 | 25 | Note
2 | 1 | 15.60 | 30 | Note
...


SELECT * FROM table where products_id= ' 1 ' ORDER by ID limit 1. Remove the last updated, product number 1.
SELECT * FROM table where products_id= ' 1 ' Remove all product number 1
------Solution--------------------
Key=>value
------Solution--------------------
This can be stored in the form of a serialized array, which is removed when needed to restore the array.
Serialize ()
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.