What is wrong with this SQL schema?

I am developing my first database for MySQL, and the idea is that we have orders that may contain several different elements. Therefore, I decided to save the order with all the necessary information in one table, elements in another, and then create a third table in which each ordered element is stored. Of course, every time I need to list an order, I will first need to find every OrderedItemsID for which the OrderID matches the OrderID I need and what corresponds to this element.

Now, since this is my first DB design, I'm not arrogant enough to think this is a good solution, so I was wondering if anyone knows a good solution for this kind of problem? Thanks

image is at http://img211.imageshack.us/img211/5575/stackoverflowq.png

+5
source share
3 answers

This solution is in order, although in the table of orders I would put the total price, tax and delivery. This way you do not have to go to the OrderItems table to get the totals.

In addition, you will want to save everything from the item in the orderitem table. This will include a name and description. The reason is accountability. If someone changes the name of the item in the table, it will significantly change it to receive a receipt. and you do not want to do this.

basically it says that all the information in the order tables should not rely on actual item tables.

, , , .

+4

, . , OrderedItem. (, , , , ) (, , ), .

0

All Articles