Results 1 to 8 of 8
  1. #1
    Harry2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    4

    Question Establishing a simple relationship?

    Hi everyone,

    I am trying to establish a relationship between two tables - and enforce referential integrity.

    I have two tables: A and B.

    However, there is data in Table A which is not in Table B and vice versa.



    Can anyone recommend an approach in which I am able to enforce referential integrity between the two tables?


    Many Thanks,

    H

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Don't understand this relationship. What are the PK/FK fields? Is one of these tables a 'lookup' source for data entry into other table?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Harry2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    4
    Hi June 7,

    -No, one of the table's is not a lookup source.

    Table A: Social security number (PK), first name, last name, address.

    Table B: Social security number (PK), email address

    Table A and Table B do not have the exact population, there is some overlap where some people are in table A who are not in Table B. And there are some people in Table B who are not in Table A.

    However, in the future more email addresses will be sourced and added into Table B.
    Also, some people added into Table A.

    Do you know a relationship / method that can be built into Access to incorporate this kind of scenario?

    Kind Regards,
    H

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    No, I do not. If you are allowing unrelated records then referential integrity is already violated. Why not 1 table?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Harry2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    4
    Ah I see what you're saying..

    Could a third table be built (Table C) which would contain all the PK's of table A and lookup the email addresses from Table B.
    Thus, Table A could link to Table C via a one-one relationship, while also enforcing referential integrity?

    This is just a scenario I am thinking of, where there would have to be two tables (in reality these tables would contain hundreds of fields each and therefore it would be more sensible to separate them for ease of updating).
    Thus, I would not be able to just add the email address field into Table A - but I see where you're coming from.

    Sorry, I'm new to Access - if I'm not making sense!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    A table with 'hundreds' of fields has the scent of non-normalized data structure.

    Your third table concept accomplishes nothing and really doesn't make sense and does not enforce relational integrity of TableB. Tables don't do 'lookup'. Use a query, don't build another table.

    You said there are records in TableB with no relationship to records in TableA. A table or query of only the TableA PK's would not retrieve those unrelated records.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Harry2 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    4
    Ah thanks, starting to get a clearer picture now!

    The issue is that I have two tables with records in Table A with no relationship to Table B?
    e.g. the PK 111 in Table A does not have a corresponding PK 111 in Table B.

    However, say in the future, when I source more data, I may come across this PK 111 and add it to Table B.
    Therefore, the PK 111 in Table A would now have a corresponding PK 111 in Table B.

    That's basically the issue I'm having

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What referential integrity do you want to manage?

    Examples:

    1. An Orders table cannot reference a product that is not listed in Products table but products can be listed in Products table that have not yet been associated with an order - can delete the order but products remain in Products table

    2. A Contacts table can have a record (contact name, address, phone) but no related record(s) in the Emails table. Could not be an EMail record without related Contact record because if contact is deleted its associated email record(s) also delete (Cascade Delete).
    Last edited by June7; 06-16-2014 at 05:14 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 1
    Last Post: 03-23-2014, 11:27 PM
  2. Access Tables establishing PK and RI
    By Spanky2012 in forum Access
    Replies: 1
    Last Post: 11-08-2012, 02:53 AM
  3. Establishing Limits
    By Niki in forum Access
    Replies: 4
    Last Post: 04-07-2011, 12:01 PM
  4. Replies: 0
    Last Post: 10-21-2010, 08:24 AM
  5. Simple Export Not So Simple
    By jgelpi16 in forum Programming
    Replies: 11
    Last Post: 09-01-2010, 07:23 AM

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