Reputation: 277
What is the best structure for an Orders table having OrderNumber, ItemNumber and CustID that allows for 1 or more item numbers for each order number?
Upvotes: 2
Views: 16625
Reputation: 1
I design it as following.
1) Customers Id, Name, address...
2) Items Id, itemname, currentprice...
3) Orders Id, customerid, date...
4) OrderItems Id, orderid, itemid, quantity, unitprice...
5) payments id, orderid, paymentdate, amount, ref, payby....
Upvotes: 0
Reputation: 20485
basket/order - table
1 : order-id -- item-id -- item-count/Quantity
cust/order history table
2 : cust-id -- order-id -- status (when you find out who the cust is)
Upvotes: 1
Reputation: 247
I highly suggest you normalize this properly and use two tables: an Orders table which keeps a record for every order and an OrderItem table, which keeps the order key (referencing back to the Orders table), the item number and quantity as well as subtotal/total price. This way, if you also need some customization (discounts, packaging fees etc) you can do so easily.
Upvotes: 2