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.
I would go with 3 tables :
product table -- which is quite independant from the ordering system, and is used by the website to just display productsorder table, which stores the basic informations of an order (like who ordered, the billing address, ...)order_product join-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 orderIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With