Here is the original model -- at least as worded in the question.
Though there is nothing cyclical here it does have few problems. For example, the model has no relationship between County
and District
, although you do state that "District has many Counties". It is also possible to have StudentRecord {RecordId, TeacherId, CountyId}
such that that teacher does not teach in the district the county is located in.
One possible fix may look like this, though I do not think this would be complete solution, but it may be a good starting point. I will use predicates -- marked by | -- and constraints (italics) to describe the model. Predicates map to tables and constraints to PK,AK, FK.
| District (DistrictId) exists.
District is identified by DistrictId.
| County (CountyCode) is located in district (DistrictId).
County is identified by CountyCode.
Each county is located in exactly one district; for each district that district may have more than one county.
If a county is locaeted in a district, then that district must exist.
| Teacher (TeacherId) exists.
Teacher is identified by TeacherId.
| Teacher (TeacherId) is licensed to teach in district (DistrictId).
For each teacher, that teacher may be licensed to teach in more than one district.
For each district, more than one teacher may be licensed to teach in that district.
If a teacher is licensed to teach in a district, then that teacher must exist.
If a teacher is licensed to teach in a district, then that district must exist.
| School (SchoolId) is located in county (CountyCode), district (DistrictId).
School is identified by SchoolId.
For each school, that school is located in exactly one county, district.
For each county, district; more than one school may be located in that county, district.
If a school is located in a county, district; then that county must be located in that district.
| Teacher (TeacherId) teaches in school (SchoolId), in district (DistrictId).
Each teacher may teach in more than one school in a district.
For each school in a district it is possible that more than one teacher teaches in that school.
If a teacher teaches in school in a district, then that school must be located in that district.
If a teacher teaches in school in a district, then that teacher must be licensed to teach in that district.
| Student (StudentId) exists.
Student is identified by StudentId.
| Student (StudentId) attends school (SchoolId).
Each student may attend more than one school, for each school is is possible that more than one student attends that school.
If a student attends school, then that student must exist.
If a student attends school, then that school must exist.
| Student record (RecordId) was generated for student (StudentId) by teacher (TeacherID) in school (SchoolID).
Student record is identified by RecordId.
If a student record was generated for a student by a teacher in a school, then that student must attend that school.
If a student record was generated for a student by a teacher in a school, then that teacher must teach in that school.
RecordId
pointer, but rather STUDENTRECORD does contain a CountyCode pointer.