Multiple Primary Keys???

  • Thread starter Thread starter slim
  • Start date Start date
S

slim

I've seen in a database file taken from a text book
entitled Exploring Microsoft Access 2000 called "Computer
Store" that there are 2 primary keys in the "Order
Details" table. How is this possible? I try to add another
Primary Key to this table and it deletes the 2 original
Primary Keys.
Any help on this??????
 
I don't have that book, but I'm guessing that what you're seeing is not
really two primary keys, but two fields which make up a single primary key.
This would be represented with the key symbol to the left of each of these
fields in design view.

If you look in the Indexes Dialog (View - Indexes), you'll see that there is
one key name for these two fields.

If you simply select another field and click on the Key icon, that
single-key primary key will delete the existing one.
But you can select multiple fields (using Shift or Control), then click the
Key icon.
Or you can set up the key explicitly in the Indexes dialog.

HTH
- Turtle
 
You can select two (or more) fields to have ONE composite primary key (you
will be able to have non-unique values in Field1 or Field2, but not in both
of them at the same time).

Anyway, it's a better practice to use an autonumber field as the primary
key, and create an index with your "Field1" and "Field2".

Take a look at this article: "Why to avoid composite primary keys" ==>
http://www.utteraccess.com/forums/showflat.php?Cat=&Board=accessfaq&Number=247916&fpart=&PHPSESSID=

[]
Luiz Cláudio C. V. Rocha
São Paulo-Brazil
 
Back
Top