Multiple Primary Keys

MsNaniB

Registered User.
Local time
Today, 10:01
Joined
Jul 12, 2011
Messages
33
Hello Everyone!

Is it possible to have 2 or more PKs in a table? Is it even necessary? Is having 'autoNumber' as the PK good enough?

Thanks,
The Novice (Nani):confused:
 
Do you mean 2 Primary Keys or 2 or more fields making up a Primary Key (AKA a Composite Key)?

You cannot have 2 Primary Keys in a table (by definition a PK is a unique identifier for a record in a table). You can index another field to disallow duplicates if you wish.

You can have 2 or more fields making up a Composite Primary Key where the combinations of these fields' values are unique. (typically used in the 'join-table' for a many-to-many relationship).

Autonumbers are almost always sufficient for a Primary Key (indeed that is their ONLY purpose) - however - surrogate keys versus natural keys causes an almost religious debate amongst database propellor-heads! :rolleyes:
 
Hi Steve!
Thanks for your help. Yes, when I say "multiple primary keys" it's just because that's how my untrained mind thinks of it...lol...sorry. My boss wants 2-3 fields to make up the primary key and I wasn't sure if this was even possible and I definitely am not sure how to structure the "joint" table. So here is some data:
I have a huge table that contains a Budget# like "BenJun1" and also an account# that is special to the Budget#, like "6046601". From this data, can you tell me how to produce what I'm looking for?
Thank you!
Nani
 

Users who are viewing this thread

Back
Top Bottom