Results 1 to 12 of 12
  1. #1
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76

    Question about foreign key if more that one field is placed in another table

    Hi,

    Is it possible to have more than 1 field in a table placed into another table as part of a relationship? If so, if you put two fields:borrowerID and borrowerName into Lenders table, must both of them be primary keys? Assuming borrowerID is a primary key of a table called Borrower.

  2. #2
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    BorrowerName should go in the Borrower table.

    If you need to create a report that shows BorrowerName with the associated lender's information, then first create a query that joins the Borrower and Lenders tables, then use that join query as the record source for your report.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Agree. The point is, don't duplicate data. There is no reason to save the BorrowerName to Lender table. Retrieve the related data by joining tables in query on the key fields. That's what they are for.
    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.

  4. #4
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76
    Quote Originally Posted by pdebaets View Post
    BorrowerName should go in the Borrower table.

    If you need to create a report that shows BorrowerName with the associated lender's information, then first create a query that joins the Borrower and Lenders tables, then use that join query as the record source for your report.
    Can you explain to me which what query should i use? For my case i want to do it on a form : The user selects a BorrowerID(Displayed in a option box allowed with the name) and then updates Lender information based on the ID.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The form is bound to the Lender table? Option box (a combobox?) is bound to the BorrowerID field of Lender table? Done.

    The query joining tables would be needed in a Report so that the related BorrowerName could be displayed.
    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.

  6. #6
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76
    Quote Originally Posted by June7 View Post
    The form is bound to the Lender table? Option box (a combobox?) is bound to the BorrowerID field of Lender table? Done.

    The query joining tables would be needed in a Report so that the related BorrowerName could be displayed.
    Lol alright i understand what your previous post is trying to do which seems more difficult than what im requesting now hah.

    EDIT:What about displaying the borrower name in the combo as well? How do i do it since i have no borrowername field in the Lender table?


    Now im reading more on queries now than you mentioned it which may be useful in the future. I guess ill try to do it first instead of visualising everything.

  7. #7
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    First, is there a many to many relationship between Borrowers and Lenders? Can you have a Lender with more than one Borrower? Can you have a Borrower who borrows from more than one Lender? If the answers to these last two questions is yes, then you have a many-to-many relationship and that requires a LenderBorrowers table, linking the two.

  8. #8
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76
    Quote Originally Posted by pdebaets View Post
    First, is there a many to many relationship between Borrowers and Lenders? Can you have a Lender with more than one Borrower? Can you have a Borrower who borrows from more than one Lender? If the answers to these last two questions is yes, then you have a many-to-many relationship and that requires a LenderBorrowers table, linking the two.
    its a one to many relationship one borrower can have many lenders but thats not my concern right now its about the combox box as ill be quite happy if i solve this one for now.Hopefully June or any else can help me to find a solution asap as im stuck in a rut right now lol

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Use a multi-column combobox for the BorrowerID and Name. Review this tutorial http://datapigtechnologies.com/flash...combobox3.html
    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.

  10. #10
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    OK, just checking. By far the most important thing to do is to get your tables and relationships in order before proceeding with form design.

  11. #11
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76
    Quote Originally Posted by June7 View Post
    Use a multi-column combobox for the BorrowerID and Name. Review this tutorial http://datapigtechnologies.com/flash...combobox3.html
    Thanks for the video. So just to clarify as long as i dont change the bound column in data type and my 1st column is borrowerID(and i can put any field in the second column and it would affect outcome ), the new lenders data i enter will always be based on the borrowerID i selected right?

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    'would [NOT] affect outcome' - aside from that, think you have correct understanding
    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. No sure how to use foreign key in the design
    By RickyLing in forum Database Design
    Replies: 0
    Last Post: 07-25-2011, 03:04 PM
  2. Replies: 4
    Last Post: 05-11-2011, 03:06 AM
  3. Foreign keys in a consolidated table
    By threepwoodjr in forum Database Design
    Replies: 3
    Last Post: 01-14-2011, 11:25 PM
  4. Multiple foreign key in table
    By pmstirling in forum Database Design
    Replies: 10
    Last Post: 02-23-2010, 04:00 PM
  5. Getting a foreign key set
    By bkelly in forum Access
    Replies: 5
    Last Post: 08-18-2009, 09:22 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