I am trying to construct an e-commerce database but I don’t understand relationship between orders, products and customers.
There are lots of database examples but they are too complex. Is there a simpler explanation or an example about possible tables and relationships.
Thanks.
This is the simplest form if customers can have more than one order and orders can be for more than one product:
The
ORDERtable has information about the date and status of the order.The
ORDER ITEMtable has information about the quantity of the product ordered.The only way to get simpler than this would be if you have a business rule restriction that says “I don’t keep track of my customers from one order to the next” or “each order is for exactly one item”. If you did have these (unrealistically simplistic?) rules, then you could reduce the number of tables in your model.
Note that this very simple model starts to get much more complicated very quickly the more flexible and realistic you want it to be. Adding in pricing, payment methods, payments, or inventory, for example, would all add a lot of complexity.