cricketbird
Registered User.
- Local time
- Today, 10:42
- Joined
- Jun 17, 2013
- Messages
- 123
I'm using homerooms and students as an "easier to grasp example" for my more complex case...
Business logic: One student can only be in a single homeroom. But, a homeroom can have many students.
I have a form with the homeroom table as the datasource, with a subform listing the associated students. On this form, you should be able to add students to the homeroom (by adding a new record at the bottom of the subform datasheet) and (theoretically) delete students from homerooms (by deleting the record/student from the subform datasheet).
However, I'm having trouble setting up the relationship between these two tables to make the form work as expected.
Attempt A:
(* = primary key)
Attempt B:
Since each student can only belong to one homeroom, I can also just incorporate homeroom directly into the Student table.
Questions
Business logic: One student can only be in a single homeroom. But, a homeroom can have many students.
I have a form with the homeroom table as the datasource, with a subform listing the associated students. On this form, you should be able to add students to the homeroom (by adding a new record at the bottom of the subform datasheet) and (theoretically) delete students from homerooms (by deleting the record/student from the subform datasheet).
However, I'm having trouble setting up the relationship between these two tables to make the form work as expected.
Attempt A:
(* = primary key)
- Students table (*studentID, studentName)
- Homeroom table (*homeroomID, homeroomName)
- Students-Homerooms linking table (*studentID, *homeroomID)
Attempt B:
Since each student can only belong to one homeroom, I can also just incorporate homeroom directly into the Student table.
- Students table (*studentID, studentName, homeroomID)
- Homeroom table (*homeroomID, homeroomName)
Questions
- I'm leaning towards version A - it feels more normalized to me. Do I then just test every entry, perhaps via a "Before Update" event, to see if that student already has a homeroom elsewhere and handle that error at that time?
- I'm currently testing version B and it feels like a complex VBA decision tree on the "Before Update" event to catch all possible types of entry (adding a new student, swapping a student from one homeroom to another, deleting one student, deleting multiple students).
- Both ways feel like I'm missing something obvious and that if I just set up the relationship better a lot of these issues would be handled seamlessly by Access.