jeudi 2 avril 2020

Searching a tree on branch nodes, but filtered by leaf nodes and sorted by number of relevant leaf nodes

For example, imagine a system that contains all the students registered in a state/province. The state is split into school boards, school boards are split by schools, schools can have individual students. For each student, relevant information like age, grade, and GPA is stored. This is all stored in a MySQL db in the most obvious way.

I want to have a page where a user can view lists of school boards by attributes on the students. Say, show me all the school boards that have students with a 3.0 avg. Further, I want to order the results by the school boards that have the most students that match the filter, and so on.

Hence the above description - searching a tree for branch nodes, but filtered and ordered by the leaf nodes

This is being done for a webapp, so we'd only be needing to show the top 10 results on the first page. However, I haven't been able to figure out a way to do this without searching the entire set of students in the entire system, then searching all the schools that those students are a part of, then finding the associated school boards, then once I have all that, sorting them all to get the top 10 school boards.

Thought about ways to do this via a SQL db and by using ElasticSearch.

Hopefully this isn't too open ended a question but I feel like I'm missing out on a key programming design pattern or something and just don't know how to describe this problem accurately enough to find it on google.

Aucun commentaire:

Enregistrer un commentaire