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
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)
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 ---
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.
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.
and 1:M on issues:RFCs already
No more relationships or tables are needed.