I am currently creating a custom e-commerce site (in php, but that's not really relevant for this question).
I have just got to creating the shopping basket, and cannot decide between the following 2 options:
option 1:
Basket table:
- id
- user
- items
In this option, I would have one row per user, with all of the items and quantities stored in the items field.
This format is already used in the cookie based basket for non-logged in users, so parsing of the items field is no problem.
option 2:
Basket_items table:
- id
- user
- item
- quantity
In this option, I would have one row per item in the basket.
option 3:
suggest a better idea.
conclusion
Both of these options are equally easy for me to implement, so the question comes down which would be more efficient/convenient for updating the basket.
Thank you for any answers, Nico