Results 1 to 9 of 9
  1. #1
    eeps24 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    39

    Question Is it best to join as many primary keys to ther tables as possiable?

    I have 3 questions if someone can please explain regarding joining primary keys to other tables.



    1. lets say theres (for example) 10 primary keys that exist on table A and table B. Is it best to join all 10, or would joining fewer have better results?

    2. (on the picture I posted below) Notice the red arrow pointing to the field "po_number" on table dbo_mainvmsg and dbo_mainvdtl. Its a primary key only on 1 table, do you still join that because its a primary key?

    3. (on the picture I posted below) notice the red arrow pointing to the field "item" on table dbo_mainvdtl and dob_poline. This is not a primary key on either table, would I still join them? Or is joining only for primary keys?

    Thank you

    Click image for larger version. 

Name:	access.JPG 
Views:	6 
Size:	118.0 KB 
ID:	21822

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  3. #3
    eeps24 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    39
    Thank you Orange for those links, I will certainly read them but I was wondering if there was a quick answer to those questions? As I am in the middle of working on this report thats giving me an issue.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    There is only 1 primary key per table. It may be a composite primary key meaning that it is made up of 2 or more fields.

    It is difficult to answer your specific questions without knowing something about
    a) your business, and
    b)where the database relationships in the diagram came from.

    In related tables, you would normally have a Primary key in Table X, and Foreign key in Table Y.
    This indicates that each record in Table X is uniquely identified by the Primary key value. All records in table Y that relate to a record in Table X have the same value of the Primary Key(table X) in the foreign key field in Table Y.

    Now based on your 3 questions:

    1 NO - join PK and FK to get matching records
    2 "
    3 "

  5. #5
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Oranges answer is the best. You don't understand how the relationships work and why we need the keys.

    The key is the unique field in a table used to reference specific records.

    EG. A contact works for a company. the company has many staff (contacts) so its a good idea to store the data about the company separately from its staff.

    on the contacts table you have specific details about the contact, then you reference the company he works for using the key from company.

    company 1 (company_ID) = company details (whatever you want to store about the company. )

    then in contacts.. have whatever info you want then reference the company using the ID. in the contacts form have a field called company ID and match it up. its simple.

    In forms you can click the company name and still in the tables the ID is stored not the lengthy data such as the address.


    that's a bit long winded and probably hard to follow but.. the keys just link information. so you have less data. you only ever need one link between data. although there can be several ways to achieve that link.

  6. #6
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    I feel bad for you mate, it looks like you have done a lot.

  7. #7
    eeps24 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    39
    Thank you guys I have to digest this information. I guess Joining primary keys to primary keys was a bad idea. I should be primary to foreign.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Primary to foreign provided there is a relationship between the "entities"/tables. It is your business facts that determines relationships.

  9. #9
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    there's a few short youtube series that would help you a lot.

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. Primary Keys for Tables & Forms
    By Tantum4 in forum Access
    Replies: 9
    Last Post: 02-04-2015, 06:07 AM
  3. primary keys in four different tables
    By greatlhanderz_15 in forum Access
    Replies: 5
    Last Post: 01-30-2013, 10:04 PM
  4. Replies: 1
    Last Post: 05-24-2012, 09:35 AM
  5. Replies: 2
    Last Post: 09-22-2010, 02:25 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