Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ChildSchoolRelation part of Child entity #693

Open
TheSlimvReal opened this issue Mar 4, 2021 · 2 comments
Open

Make ChildSchoolRelation part of Child entity #693

TheSlimvReal opened this issue Mar 4, 2021 · 2 comments
Labels
Status: Idea to be considered and discussed - don't start work yet Type: Improvement Improvement/Extension of existing feature with benefit for the user Type: Refactoring / Technical Enh. Technical Enhancement without changes for the user
Milestone

Comments

@TheSlimvReal
Copy link
Collaborator

TheSlimvReal commented Mar 4, 2021

Problem
Currently, we have the ChildSchoolRelation objects which link children to schools in a M:N relationship. This has quite bad performance, because often additional database requests need to be made for linked entities (in the ChildrenService, a call needs to be made for each child to get the current school).

Solution
Make the ChildSchoolRelation part of the Child entity by adding a schoolHistroy property to this class. This property is an array of objects, which contain the ID of the visited school, the class and a start and end date. To make it possible to get all children that are currently visiting a certain school, a view needs to be built which for each child emits the schooldID for each entry in schoolHistory that does not have an end date (and directly include the child document using linked documents.
A data migration for current users needs to be implemented.

Outlook
This solution could be implemented very flexible. Which would allow to define any kind of M:N relationship as a property. It could be evaluated whether this can be one with a moderate amount of work.

@TheSlimvReal TheSlimvReal added Type: Refactoring / Technical Enh. Technical Enhancement without changes for the user discuss Status: Idea to be considered and discussed - don't start work yet Type: Improvement Improvement/Extension of existing feature with benefit for the user labels Mar 4, 2021
@TheSlimvReal
Copy link
Collaborator Author

TheSlimvReal commented Mar 4, 2021

The 1:N relationships for the Aser, EducationalMaterial and HealthCheck entities could also be replaced by arrays on the respective Child object. Would this be desired?

@TheSlimvReal
Copy link
Collaborator Author

TheSlimvReal commented Mar 4, 2021

The approach has the downside, that more write operations are performed on the Child object which might cause more conflicts see best practices. Alternatively, to query the children with their schools at the same time, view collation can be used -> #694 .
It should be discussed whether the advantages (less DB calls, easier data model, direct access to the properties for sorting etc.) exceed the disadvantages (more conflicts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Idea to be considered and discussed - don't start work yet Type: Improvement Improvement/Extension of existing feature with benefit for the user Type: Refactoring / Technical Enh. Technical Enhancement without changes for the user
Projects
Status: Triage / Analysis
Development

No branches or pull requests

2 participants