2008-12-21, 15:59
My mind has gone blank here for some reason. I can't be sure that my solution to this problem actually works or not, but here goes:
I have a company that sells widgets. There is a table containing the data for each widget type; widgetID (primary key), name, description, price etc.
I have a table for orders, which has the orderID (primary key), order number, a checkbox for if the payment has cleared (they accept cheque), and where the order came from (web, mail order, or phone).
Problem is, customers can order more than one type of widget per order.
What I have implimented is a linking table that has widgetID, salesID (primary key), orderID, quantity.
Does this actually work? In theory, the linking table will hold all of the widgets of all of the orders, like so:
I *think* this works, but I would like a second opinion on it before I start populating the database properly.
Thanks
(Yes, I do get very bored when I don't have decent internet/computer access
)
I have a company that sells widgets. There is a table containing the data for each widget type; widgetID (primary key), name, description, price etc.
I have a table for orders, which has the orderID (primary key), order number, a checkbox for if the payment has cleared (they accept cheque), and where the order came from (web, mail order, or phone).
Problem is, customers can order more than one type of widget per order.
What I have implimented is a linking table that has widgetID, salesID (primary key), orderID, quantity.
Does this actually work? In theory, the linking table will hold all of the widgets of all of the orders, like so:
Code:
salesID widgetID orderID quantity
0001 2345 0001 3
0002 6868 0002 6
0003 9999 0002 1
0004 6868 0003 12I *think* this works, but I would like a second opinion on it before I start populating the database properly.
Thanks
(Yes, I do get very bored when I don't have decent internet/computer access
)