Results 1 to 2 of 2
  1. #1
    RustyRick is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    NW Alberta
    Posts
    53

    Foreign Keys

    Foreign Keys to NOT yet have asylum in my head yet?

    I know what FK are for - linking tables. I know where they sit in tables. I have watched countless YouTube videos and in my 73 year old mind nobody has clearly defined them?

    I see example like "CONTACT Number", and "ContactNumber" being used and called Foreign Keys. Spelt different on 2 different tables. I understand they both must be the same data type.

    BUT - I don't understand what exactly determines that 2 field descriptions become Foreign Keys?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    it is defined in relationships. Many of the templates and examples you will find try to 'keep it simple' rather than being 'correct'. PK's are unique to a table, you will never find a duplicate. FK's can have duplicates because they relate back to one PK. The field names themselves are irrelevant but my own preference is to name fields with a PK or FK suffix to identify which end of a relationship a field is. Using an invoice as an example - you have one invoice header record (has a PK), but many invoice lines that relate back to that one invoice header. So the invoice line record will have a PK to uniquely identify the individual line but also a FK field to link back to the invoice header.

    With regards field names, you should think of them in the context of the whole application, not just the table. So 'ID' or 'Description' may be sufficient within the context of the table, but not the application - ID of what? description of what? Better to use a name like 'customerFK', 'customerPK', 'ProductDesc', etc

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

Similar Threads

  1. Redundant Foreign Keys?
    By kd2017 in forum Database Design
    Replies: 9
    Last Post: 07-25-2017, 11:11 AM
  2. Foreign keys
    By Accessuser67 in forum Access
    Replies: 1
    Last Post: 10-05-2015, 06:33 PM
  3. Extracting Foreign Keys
    By QuantifyRisk in forum Forms
    Replies: 7
    Last Post: 08-08-2014, 02:05 PM
  4. Query with Foreign Keys
    By BawdyB in forum Queries
    Replies: 5
    Last Post: 05-15-2013, 06:47 PM
  5. Need help with foreign keys
    By acdougla17 in forum Access
    Replies: 1
    Last Post: 09-26-2011, 03:50 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