Thread: 2 field primary key
02-24-10, 13:21 #1Registered User
- Join Date
- Jun 2006
Unanswered: 2 field primary key
I'm basing my database off the Northwind Traders example. My database is similar in that it has products and shipping/orders. In an attempt to set up my table "Order Details", I cannot seem to set my "transactionID" and "productID" fields to the primary keys, like that of the Northwind example. When I enter in the data, I get an error....
"The changes you requested to the table were not successful because they would create duplicate values....."
In my field properties for both "transactionID" and "productID", I have both Indexed set to "Yes (Duplicates Ok)". Basically, I've made the field properties of my "Order Details" table just like that of the Northwind "Order Details" table. However, mine is giving me the above error. Am I missing something? Is there some code that's running on the Northwind database that overrides that error? I have no null or blank values in my data. Any ideas?
I may have just figured out my problem. I have an extra field in my database that the Northwind database does not have. My Products table is much larger than Northwind. To make it easier to find products, I have everything organized into Categories. Thus each item has a unique ID number, a Category, and a Description. I was attempting to make the TransactionID and CategoryID in the Order Details table the composite primary key, but I kept getting the error I mentioned. I suppose all I need is the TransactionID as the primary key. Any other thoughts on this are appreciated.
Last edited by Grassy7; 02-24-10 at 14:05.
02-24-10, 13:55 #2Jaded Developer
Provided Answers: 59
- Join Date
- Nov 2004
- out on a limb
y'can't have duplicates in a primary key... a primary key is the PRIMARY key that identifies a specific row. so it has to be unique
if you have duplicates then either your design is flawed or your have redundant duplicate dataI'd rather be riding on the Tiger 800 or the Norton