It's my first try at DDD and I would like to get advise on modeling issues.
Here is my domain: The management of multiple schools.
- A school has multiple students, teachers, …
- For a school, there is (every year) a new schoolYear (which has a value object holding
2017-2018
for instance) - Classes, student scores are related to a schoolYear (for instance, Student A can be in class C1 in school year 2017-2018 and in classe C2 next year 2018-2019)
My first doubt is in the modeling of schoolYear.
I already have the school entity as a root aggregate. My first approach was to make the school aggregate handle the addition of schoolYear (so that I can avoid duplicates, or that I can create the next schoolYear, …)
=> schoolYear is part of the school aggregate
But then I had to model classes and student scores… which depend on the schoolYear.
So in my classes aggregate, I have to hold a reference to a schoolYear… which breaks the rule that states
"Cannot hold a reference to an internal entity from an outside aggregate."
In my domain, a lot of entities are depending on a specific schoolYear. Maybe it should be an aggregate…
On the other hand, the schoolYear of a given class is used for searching classes.
Can I get some advice about this modeling issue?
Another depending question is about the identity of schoolYear.
- Option A: Generate a UUID as is and holds schoolId + year as attributes
- Option B: Id is schoolId and year, so we cannot create the same schoolYear twice for the same school and the same year
Any advise on this?
Thanks a lot helping me enter the DDD world!