[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Foreign key & primary key in Access

Posted on 2009-02-12
5
Medium Priority
?
1,196 Views
Last Modified: 2013-11-27
Can you have a field which is a primary key also to be a foreign key?

Many Thanks
0
Comment
Question by:AA321
  • 2
  • 2
5 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 23624078
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
 
LVL 28

Expert Comment

by:TextReport
ID: 23624345
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
 
LVL 44

Expert Comment

by:GRayL
ID: 23625183
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
 
LVL 28

Expert Comment

by:TextReport
ID: 23625292
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
 
LVL 44

Accepted Solution

by:
GRayL earned 1500 total points
ID: 23627509
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses
Course of the Month18 days, 13 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question