Primary key of two fields

E

Ellen

I have a table that has two fields, the combination of
which is unique. Can I make the combination of two fields
a primary key?

Are there limitations with this? Both fields are wordy at
places, although the combination is never more than 255
characters.

Thank you in advance,
Ellen
 
I

Immanuel Sibero

Hi Ellen,

Yes you can have two fields as a primary key (called composite key).

Limitiations? As far as using composite key as opposed to single field
primary key? Not off the top of my head, nothing major at least. But you
will find quite a good deal of conceptual debate in this newsgroup as to the
the merit of using one vs the other.

From your post, I'm more concerned about the fields that you're about to
designate as primary key (i.e. Both fields are wordy at places, although
the combination is never more than 255 characters). Primary keys should be
unique, short, probably even meaningless. So, for example a first name, last
name, description, should not be primary key(s).


HTH,
Immanuel Sibero
 
E

Ellen

Thanks, Immanuel. I think I'll give the records an
arbitrary number. There used to be a field you could
designate as an autonumber. I know that still exists,
don't know if they still call it an autonumber, though.
Also generally, the simpler the better.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top