While designing a relational database I got the questoin in my head if the design I made could be made easier. The design consists of 4 tables: (simplified)
- location
- office
- school
- group of schools
PK = primary key,
FK = foreign key
Lets say we want to get details about a location. If the location is a school we want to see the name, amount of students and the name of the group of schools its part of. If it is a office we only want to see the name of the office. With the current design this is impossible to do in 1 query (with my knowledge).
question: Is there a better way to design this database so I can get the needed details about a location in 1 query.
Although there may be a way to get these details in 1 query I am more interested in enhancing the database design.
Thanks in advance, Knarfi
ANSWER: I finally found the term that describes my problem: Polymorphic Association. Especially this question gave me a good answer.