I'm trying to model a problem where a Company has many Teams. There is a business rule that "the name of the team must be unique per company". However, a Team has many other behaviours, such as joining. Also, a Team can have many Reports - which maintain a reference to Team.Id.
At the moment, Team and Company are separate Aggregate Roots. In order to enforce the invariant that Team.Name must be unique per Company, should I could create a Team Entity within the Company Aggregate which is only responsible for the creation and renaming of Team? I believe Company must create Team in order to enforce the rules, and be responsible for renaming, but that is all.
My question is: is this normal? Is splitting a domain concept across Aggregate Boundaries a normal way to enforce invariants?
The only alternative I can see is to move the entire Team Aggregate into the Company Aggregate. But in this case, I'll be storing a reference to a non-aggregate within Report.
I'd imagine this is a common modelling problem, but Google is failing me!
Any help is much appreciated!
Aucun commentaire:
Enregistrer un commentaire