I have a problem with a table design when a Foreign Key refers to a Primary Key with two columns.
Three simple example tables (all fields text, other data fields omitted) to illustrate my problem are:
Tables: Fields
Departments: Name (PK)
Mentors: Department (PK1 and FK to Departments), Name (PK2)
Trainees: Name (PK), Department (FK to Mentors), Name (FK to Mentors)
There may be 0 or many Mentors in a Department.
Mentors.Name is only unique within a Department, so Department has to be part of PK.
Trainees may have no Department or Mentor.
Trainees may have a Department and Mentor which exists.
All the above works fine. However the problem is:
If a Trainee has a (valid) Department, but a Mentor has NOT been assigned, then Access (2003 on XP Pro) will not allow a Trainee row with a valid Department but with a blank (Null) Mentor.
I have been puzzling for some days over how to change my design to allow this last case, while retaining the Referential Integrity!
Any suggestions welcome! Have I overlooked something simple?
Thanks
Three simple example tables (all fields text, other data fields omitted) to illustrate my problem are:
Tables: Fields
Departments: Name (PK)
Mentors: Department (PK1 and FK to Departments), Name (PK2)
Trainees: Name (PK), Department (FK to Mentors), Name (FK to Mentors)
There may be 0 or many Mentors in a Department.
Mentors.Name is only unique within a Department, so Department has to be part of PK.
Trainees may have no Department or Mentor.
Trainees may have a Department and Mentor which exists.
All the above works fine. However the problem is:
If a Trainee has a (valid) Department, but a Mentor has NOT been assigned, then Access (2003 on XP Pro) will not allow a Trainee row with a valid Department but with a blank (Null) Mentor.
I have been puzzling for some days over how to change my design to allow this last case, while retaining the Referential Integrity!
Any suggestions welcome! Have I overlooked something simple?
Thanks