This image shows an example of the data relationships I have. I’ve used schools to make it easy to visualize.
For any school I can easy show what teachers are at that school e.g for school A1 I would have Bob and Jane.
What I want to do is if I am at a county level is to get all teachers of that county e.g for county A1 would return the teachers Bob, Jane, James and Derek
And if I am at the state level it would return all teachers below this state.
Is there any way to do this?
The only way I can think of doing it is store for each teacher an array of ids that correspond to each level up then when I’m at a state or county level search for all teachers and see if that state or county id exists in the teachers array.