DevastatioN
Registered User.
- Local time
- Today, 02:01
- Joined
- Nov 21, 2007
- Messages
- 242
Hello,
I was taught that having a loop of relationships is a bad thing to have. My dilemma comes from the following:
I have a table let's say that has user data, which contains a field for Province, and City they live in. Now, clearly City and Province have to also be related. This would effectively create a relationship loop as follows:
tblEmployee: ID, Name, Province (Linked to tblProvince), City (Linked to tblCity)
tblProvince and tblCity are also linked.
One way to stop this, is simply to not include the Province in the main table... snice once you enter the city, it's obvious which province the employee belongs to. However on the main form, a user will most likely wish to "Filter the city, based on province selected".
This is entirely hypothetical, but I ran into something similar in real practice. Which is better? To create the relationship loop in the database, or to find a workaround?
Attached is a tiny example database of what I did to make this work without creating a relationship loop, but I was wondering how bad a relationship loop really is, in this type of situation where it sounds very logical.
Another example I have run into, let's say we have tblInstructors, tblStudents, and tblClasses. Clearly classes have students and an instructor, and everything is joined properly (Junction table between students and classes, one to many between classes and instructors etc.). But now let's add the fact that Students and Instructors are all military members and have a "rank" associated with them. Each instructor has a rank, and each Student has a rank. This is easily stored in a tblRanks, however linking this table to both tblStudents and tblInstructors creates a relationship loop.
The problem here is, tblRanks isn't only the ranks, but contains info on the ranks as well. How can you generate a query that shows each student and their rank, the classes they have taken, the instructor that taught that course, and that instructors rank.
So what do you guys think? (Attached is my City/Province workaround).
I was taught that having a loop of relationships is a bad thing to have. My dilemma comes from the following:
I have a table let's say that has user data, which contains a field for Province, and City they live in. Now, clearly City and Province have to also be related. This would effectively create a relationship loop as follows:
tblEmployee: ID, Name, Province (Linked to tblProvince), City (Linked to tblCity)
tblProvince and tblCity are also linked.
One way to stop this, is simply to not include the Province in the main table... snice once you enter the city, it's obvious which province the employee belongs to. However on the main form, a user will most likely wish to "Filter the city, based on province selected".
This is entirely hypothetical, but I ran into something similar in real practice. Which is better? To create the relationship loop in the database, or to find a workaround?
Attached is a tiny example database of what I did to make this work without creating a relationship loop, but I was wondering how bad a relationship loop really is, in this type of situation where it sounds very logical.
Another example I have run into, let's say we have tblInstructors, tblStudents, and tblClasses. Clearly classes have students and an instructor, and everything is joined properly (Junction table between students and classes, one to many between classes and instructors etc.). But now let's add the fact that Students and Instructors are all military members and have a "rank" associated with them. Each instructor has a rank, and each Student has a rank. This is easily stored in a tblRanks, however linking this table to both tblStudents and tblInstructors creates a relationship loop.
The problem here is, tblRanks isn't only the ranks, but contains info on the ranks as well. How can you generate a query that shows each student and their rank, the classes they have taken, the instructor that taught that course, and that instructors rank.
So what do you guys think? (Attached is my City/Province workaround).