Accessme2
07-12-2004, 12:35 PM
Hi everyone,
Is there a magic max number of primary key a table should have or just as many as it takes to make the record unique.
Thanks
Calvin
07-12-2004, 01:02 PM
One is generally enough for most processes and new processes. Only when the process requires it, for example working with legacy data collected from an old process, have I needed to use two or three PK's to uniquely ID a record and the new process would not allow the concatination or changing of the legacy data into one field.
Mile-O
07-12-2004, 01:09 PM
You can only have one primary key per table.
Calvin
07-12-2004, 01:15 PM
Mile-O-Phile,
Check your Doc's, and try an example yourself. You can assign multiples, for example sometimes a phone number field is not unique enough, in conjunction with a zip code field the two fields can be used together as PK's to uniquely ID the record.
And doing so will allow the same phone number to be listed multiple times but not in the same zip code, and vise-versa.
Mile-O
07-12-2004, 01:34 PM
I know - two or more fields become a composite primary key. There may be up to 32 fields used to form one primary key.
Calvin
07-12-2004, 01:45 PM
Mile-O-Phile,
Then why didn't you say that before, you only confused the issue by saying there can only be one PK, yes there is one PK definition, but 32 fields defined in the PK would have been the correct answer. You know the guy is asking how many fields can be used in a PK.
You've been on this long enought to know how to interpret questions from beginners, you should know how to post answers to beginner.
Pat Hartman
07-12-2004, 02:05 PM
Reality check - Jet only supports 10 columns in a compound pk or index.
Is there a magic max number of primary key a table should have or just as many as it takes to make the record unique. - as others have said, the magic number is 1. If you do not have any candidate keys that would be unique or combinations of 2 or 3 fields, I would suggest what is called a surrogate key - which is normally an autonumber in a Jet table.
Calvin
07-12-2004, 02:07 PM
Thanks Pat, great answer. :)
Mile-O
07-13-2004, 01:10 AM
Jet only supports 10 columns in a compound pk or index.
So it does. Where did I get 32 from? :confused: