Foreign key & primary key in Access

Can you have a field which is a primary key also to be a foreign key?

Many Thanks
AA321Asked:
Who is Participating?
 
GRayLCommented:
Normally you expect to see both keys in the many table.  However, in the example you cited you would join on both primary keys and select only those fields from each table you app allows.  I really don't know, heck, I don't even work here ;-)
0
 
peter57rCommented:
Not unless you have a 1-1 relationship between the two relevant tables.
A foreign key is usually the value of the primary  key field in the related table.
0
 
TextReportCommented:
AA321 yes you can, the time you would do it is if you are conducting a large survey and you had too many fields for a single table.
peter57r, you do not need to set the 1 to 1 relationship but most people would want to, not setting it as a 1::1 relationship could lead to missing data in both tables, whereas, with RI set you could only get missing data in the second table.
Cheers, Andrew
0
 
GRayLCommented:
Andrew, in your case would that not be a situation where the primary key of table1 is also the primary key of table2, ie., there is no foreign key in table2 per se?  'RI'??
0
 
TextReportCommented:
GRayL, isn't the foreign key just a term given to the join field(s), in Access there is no special status of the FK. So that the PK in the 2nd table is also the FK. In Access the 1::1 relationship is just a 1::M (PK to FK) where the Many table can only have 1 value in the FK

RI sorry Referential Integrity

Cheers, Andrew
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.