Which is a better db design when inserting records?
**Option 1.**
uid|itemid| qty | price | amount
1 |13| 2 | 100 |200
**Option 2.**
uid| itemid| qty | price | amount
1 |13| 1 | 100 | 100
2 |13| 1 | 100 | 100
In option 2 then retrieve rows via mysql query and calculate using id …
It seems like you want to retain the original price of each item ordered. What I’d do is go with option 1, then create another column in your table that holds a string that identifies each item in the order.
For example, if I were selling fruit, a banana could have
iZas a unique key. And an apple could have6Uas a unique key. When a user places an order, these unique keys would be inserted into your new column. So when you see this column’s data isiZ6Uyou’d know that the user ordered an apple and a banana.