Avatar of David Bigelow
David Bigelow
Flag for United States of America asked on

How should I set up the many-to-many relationships?

In the Issues table, which is the main table, I want to maintain referential integrity and be able to join multiple Defects_DCRs to one issue and/or multiple RFCs to one issue. With the current structure, I'm not sure where to place the intervening join tables or if one of the current tables, possibly the Issues table, should be the join table.

I've seen articles on this, but couldn't find one during a half hour to an hour of searching. I suppose I wasn't using the right key words. If you would also explain the logic behind the solution in a step by step format, that would help me better understand for future reference. Thank you!
RFCsTest1.accdb
Microsoft Access

Avatar of undefined
Last Comment
PatHartman

8/22/2022 - Mon
COACHMAN99

It seems you have a 1:M on issues:defects
and 1:M on issues:RFCs already
No more relationships or tables are needed.
David Bigelow

ASKER
I thought the above question would help me meet my end goal, but maybe not. My desire is to create a Defect_DCR multi-value field and an RFC multi-value field in a form (I see I didn't include a form with the sample database) with checkboxes to mark each Defect_DCR or RFC that is associated with the issue. My understanding is that the Access lookup tables are actually hidden many-to-many tables.

I could use the built in lookup tables function, but I wanted to maintain more control on being able to sort and use the data. I've attached the test database with a form.

Should I post a new question as, "How do I set up many-to-many relationships for multi value fields?"?
RFCsTest1.accdb
COACHMAN99

A M:M relationship is implemented with an 'intermediate' table holding keys from the other 2. (and a compound key is uniqueness is required)
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
David Bigelow

ASKER
According to this forum post, http://stackoverflow.com/questions/13505838/alternative-to-multi-valued-fields-in-ms-access, there really is no easy way to replicate lookup tables. I read banter about how it is better to make your own, but am not finding any examples on how to do it, which is why I came to the experts.
ASKER CERTIFIED SOLUTION
PatHartman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
David Bigelow

ASKER
Thank you, Pat.

Right now, I'm seeing I need to go back to the user to clarify what is needed.
Hamed Nasr

Simple example:
Tables:
     Students
SID Name
1 n1
2 n2
3 n3

     Courses
CID desc
1 d1
2 d2
3 d3
Relation between Students and Courses is M:M, because each student may enroll in more that 1 course, and each course can be taken by more than 1 student.
To use M:M we create a new table:
     Student_Course
SID CID desc
1      1    ---
1      2    ---
2      1    ---
2      3    ---
3      2    ---
3      3    ---

Relationships
Students:SID>----M:1-------- SID:Students_Courses:CID ------1:M-------< CID:Courses
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
David Bigelow

ASKER
I feel like I've steered the conversation off course with my initial request. Basically, I want to be able to assign more than one defect_DCR to the Issue. (I was trying to say that further up in the post). Currently, it is the other way around. More than one issue can be assigned to a defect_DCR

Update. It's starting to make sense.
PatHartman

The Parent's primary key goes into the Child table where it is referred to as a foreign key.  If your relationship is backwards, change the tables as I described.  If you have existing data that you don't want to loose, you'll need to do some cleanup first.  Add the correct foreign key but don't delete the incorrect one.  Join on the incorrect relationship and update the new foreign key with the primary key from the old table.  Once you are certain that the records are linked correctly, delete the incorrect foreign key.  Then delete the existing relationship and recreate it.
PatHartman

Why was my working sample database insufficient?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
David Bigelow

ASKER
Hello Pat,
Thank you for posting. I had to go back and reconfigure my foundational table relationships since I didn't quite understand how they should be when I intially created the database. After that, I never got back to this issue. But, you answer looks like it is what I'm looking for. I appreciate the sample you provided. It is easy to understand and follow.
PatHartman

You're welcome.  Glad it helped.

Vote early and if you're in (or near) a state that doesn't check ID's, vote often.