I’m designing my first database for MySQL and the idea here is that we have orders that can contain multiple different items.
So i decided to store order with all the relevant info in one table, items in another, and then create a third table where each ordered item is stored. Of course every time i will need to list an order i first will have to find every OrderedItemsID for which OrderID is the same as the OrderID i need and than match that to items.
Now since this is my first DB design i’m not arrogant enough to think that it’s a good solution, so i was wondering if anyone knows a good solution for this sort of problem?
Thanks
image is at http://img211.imageshack.us/img211/5575/stackoverflowq.png
This solution is fine, although, in the orders table i would put in a total price, tax and shipping. This way you don’t have to go to the OrderItems table to get the totals.
additionally, you will want to store everything from the item into the orderitem table. This will include the name and description. The reason is for accountability. If someone changes the name of an item in the table then that will essentially change it for everone’s receipt. and you dont want to do that.
basically said, all information in the order tables needs to not be reliant on the actual items tables.
you can also take this further to add in the billing and shipping address so that if the user changes this in the future it wont change for this specific order.