Results 1 to 12 of 12
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672

    FK With Tables

    Does Microsoft Access have the ability to set-up a Foriegn Key when using a many-to-many relationship?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Possibly, but not directly. Many to Many relationships in a relational database are usually decomposed into 2 One to Many relationships.
    Many--------------Many
    Student>------<Course
    becomes

    One----------Many---------------------One
    Student---<StudentTakesCourse>--- Course

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you can set relationships by going into the relationships window on the database tools tab.

  4. #4
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    my thought was....
    Machine Table
    --Each Machine gets MachineId
    Parts Table
    --Each Part Gets PartId
    Machine Parts Table
    —where we map the MachineId to the PartId
    —this is where many to many relationship comes to play
    —example
    MachineId | PartId
    1 | pt1
    1 | pt2
    2 | pt4

    next create a Vendor Part table and map just like we did in the Machine Parts table

    DOes this make sense?

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Yes.

    Can you describe the "business rules" involved?

    There may be 1 or many Machines
    1 Machine can make 1 or many Parts
    a Vendor may require 0,1 or many Parts

    or whatever relates your Machines, Vendors, Parts....

  6. #6
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Quote Originally Posted by orange View Post

    There may be 1 or many Machines
    1 Machine can make 1 or many Parts
    a Vendor may require 0,1 or many Parts

    or whatever relates your Machines, Vendors, Parts....
    Yes, that sums it up nicely.

    There will be ONE machine - but a machine is made up of many parts
    ONE part can be used for MANY machines

    Then to the Vendor/Part relationship.
    One Part can be ordered from Multiple Vendors

    That's why I thought of using the Machine Parts Table and Appliance Parts Table as sort of a "mapping" to "tie" it all together

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    What is Appliance? How is it different than Machine?
    How about describing an example?

    Machine X is made up of Parts A, B,C and is ordered by Vendor q and R

  8. #8
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Sorry - changing terminology as it goes. Machine = Appliance. I changed it to Machine as it made more sense.

    Example:
    tblMachine --
    MachineId | MachineName
    wm1 | Washing Machine
    dw2 | Dishwasher

    tblParts
    PartId | PartName
    or1 | ORing
    bh2 | Black Hose

    tblMachineParts
    MachineId | PartId
    wm1 | or1
    wm1 | bh2
    dw2 | or1


    Does that make sense?

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  10. #10
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    When you finalize your MTM table design, you'll need a way to enter and maintain data in those tables.
    Have a look at this:

    https://www.accessforums.net/showthread.php?t=79814

  11. #11
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    I like this set-up! Esp how you tied the vendor to partId.

    Seems very very similar to how I will be setting things up.

    One thing I will note tho, is that you have a FinalProduct table, and that ties to the Customer (who purchased). I'm trying to wrap my mind around how to have this work in my scenario, as we currently have an inventory of Machines already built and we will be selling them as orders come in.

  12. #12
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Quote Originally Posted by davegri View Post
    When you finalize your MTM table design, you'll need a way to enter and maintain data in those tables.
    Have a look at this:

    https://www.accessforums.net/showthread.php?t=79814
    Ohhhhh with a little tailoring, I think this would suit my needs great. Thanks for sharing!

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

Similar Threads

  1. Replies: 4
    Last Post: 11-03-2020, 10:32 AM
  2. Replies: 6
    Last Post: 04-18-2018, 06:56 AM
  3. Replies: 17
    Last Post: 04-09-2018, 04:39 PM
  4. Replies: 1
    Last Post: 12-11-2013, 01:18 PM
  5. Replies: 4
    Last Post: 11-22-2013, 11:20 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