I'm going to try to layout the tables a little clearer, just so I'm sure we are on the same page.
regUsers( uID PK, un, addr, email, etc);
orders( uID PK,orderID);
orderDetail( PK orderID, total, items (list), date, address);
product( prodectNo PK, Pname, notes, price, imgpath, stock);
Product_Type( productNo, type);
If you had given SQL then I could have probably told you what your instructor disliked. For now I can only offer guesses.
Each item in items links to products. Not sure how to write a formal link between a list of Product IDs to the product table in MS SQL server 2008
Are you familiar with the concept of foreign keys? If the answer is "no", then this is probably something your professor didn't like. Taking your regUsers
and orders
table as an example, you may want to use something like the following:
CREATE TABLE regUsers(
uID INT PRIMARY KEY,
un VARCHAR,
addr VARCHAR,
email VARCHAR,
etc VARCHAR);
CREATE TABLE orders(
uID INT PRIMARY KEY REFERENCES regUsers(uID),
orderID INT);
I selected VARCHAR
somewhat arbitrarily because I don't know anything about the data you plan on storing. The important part is that the uID
in orders REFERENCES regUsers(uID)
. This means that all uID
values in your orders
table must also exist in your regUsers
table.
Another point of interest here: you claim that you want uID
to be the PK of orders
, but uID
is also the PK of regUsers
(its foreign key). This implies that every uID
in regUsers
can have at most ONE row in the orders
table... is that what you intended? Recall that PKs are unique.
Which links to productType on productNo PK
Same issue with your Product Type
table. If you are going to make product_no
your PK for that table, then you can only have one row for each product_no
; I don't think this is what you want. If it is what you want, and every product_no
can have at most one type
, then you might consider just storing the type
in the product
table and avoiding the Product Type
table all together.
Another possible point, what did you mean by (list)? I did a quick search to see if there is a LIST
data type in MS SQL server and found nothing. Are you planning on storing a list of strings in this column? If so, then it is a good candidate for a separate table all together.
Have you thought at all about the queries you would need to execute in order to get the information you need? What data types did you assign each column? In general, a good way to start designing a schema is to create an E/R diagram, but in this case you may need to do a little more research. I could be wrong here as well, and I would be glad to revise my response if you provide the actual SQL you are using to create the tables.