Results 1 to 6 of 6
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    A primary key with two foriegn keys

    Is it possible for a primary key in a table to have two foreign keys. It seems possible
    with some modification. I just do not know.

    I have table with the primary key Personnel. Now it has two foreign keys that are in two different tables.




    When I developed the relationship with the Personnel table (with a primary key) and a table with a foreign key then things operate as they normally
    would. This is the first foreign key.


    But when I try to add a second different table but with the same foreign key, it creates a second table something like Personnel_1. In other words it takes the original table (Personnel) with the primary key and then creates a new table like Personnel_1 and uses its primary key to connect to the second foreign key.

    Can I just have the original table with a its primary key connected to two foreign keys in two different tables?


    Thanks in advance.


    Respectfully,


    Lou_Reed

  2. #2
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I just want to have this primary key with two foreign keys. But I do not want a second table with a primary key.

    Any help appreciated.

    Respectfully,


    Lou_Reed

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Where are you trying to do this - in the relationships tool or in a query?

    Your terminology is confusing - when you say "I just want to have this primary key with two foreign keys..." what do you mean? Do you have a table with a primary key (PK) in one field, and two other fields that are foreign keys (FK) to two other tables? That should not pose a problem - I do that all the time. You can also have the same FK field linking to several tables - again, not an issue.

    But your description of the problem sounds as if you have two FK fields in one table pointing to the same second table, not two different ones.

    Can you clarify things a bit?

  4. #4
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I am doing it because at our last meeting, that was what was agreed on by the people paying me.

    I said at the time that I did not know if it could be done. That is the reason for this question on the forum.

    I have single table and the primary key of that single table is connected to two different foreign keys
    in two different tables.

    Now when I set this up and added a second foreign to the primary key of the first table, the primary key table split into two tables:
    table and table_1. Each had their primary key and each primary key was attached to two different tables.

    I was wondering if I can get rid of that second table that MS Access 2010 created. Can I just use one table with its primary key connected
    to two foreign keys.

    Any help appreciated.

    Respectfully,

    Lou_Reed

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Now when I set this up and added a second foreign to the primary key of the first table, the primary key table split into two tables:
    table and table_1. Each had their primary key and each primary key was attached to two different tables.
    You are doing something wrong. Usually this happens when there is a design error (but not always).
    I have a table that is linked to 5 other tables (PK to FK) and nary a "table_1" in sight.

    Can you post a picture of the relationship window?

  6. #6
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I believe that you are correct. There is no other reason for this than the fact that the secondary table, the Table-1 table was merely
    a move for space saving. That is all it was.

    Thanks for the help!

    Respectfully,


    Lou_Reed

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Use of primary keys
    By Homegrownandy in forum Access
    Replies: 6
    Last Post: 06-29-2015, 01:17 AM
  2. Question about Primary Keys
    By Helystra in forum Database Design
    Replies: 3
    Last Post: 11-21-2013, 03:56 PM
  3. Multiple Primary Keys
    By JonathanOz in forum Access
    Replies: 2
    Last Post: 03-22-2013, 08:32 AM
  4. primary/foreign keys
    By st1300 in forum Database Design
    Replies: 38
    Last Post: 12-04-2011, 01:27 PM
  5. Multiple primary keys
    By elektrisk in forum Access
    Replies: 5
    Last Post: 02-11-2010, 04:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums