Just simple question – how to organize an orders’ table, i.e. when somebody orders 2x item with id=1 and 3x item with id=2.
My previous solution were to save it like: 2x1,3x2 in products column, and then explode() it, but it’s very inefficient.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would go with 3 tables :
producttable — which is quite independant from the ordering system, and is used by the website to just display productsordertable, which stores the basic informations of an order (like who ordered, the billing address, …)order_productjoin-table between those two, indcating, for each order, which products it contains, and in which quantity.That last table would contain, at least, the following fields :
id_order: identifier of the orderid_production: identifier of the productquantity: number of times this product has been bought in this order