Hi all,
currently I dont know how to identify an aggregate root.
I've got the following classes.
- Garage
- Organisation
- RuleSet
- Rule
- OrganisationRule
- GarageRule
A Garage
can have many Organisations
.
A RuleSet
is an entity where Rules
are referenced to.
There are Rules
that are directly associated with a RuleSet
.
Then there are OrganisationRules
that are associated with a RuleSet
and a Organisation
.
Finally there are GarageRules
that are associated with a RuleSet
and a Garage
.
The whole concept behind a rule set and its rules is, that a user can add rules to rule set on rule set level. Then these rules can be overwritten by rules defined on organisation level. Again, more specific rules can that be added for garages.
So later, a client wants to get the rules for a garage, it will first check the rules that are directly associated with a garage, then it will check for rules on organisation level, and then on rule set level.
My problem now is to identify the aggregate roots. Plus, if for example RuleSet is the aggregate root of all rules, I dont know how to do performant queries to get a rule for a specific garage (there are about 60000 garages).
So e.g.:
public class RuleSet
{
public ICollection<Rule> MetaRules { get; set; }
public ICollection<OrganisationRule> OrganisationRules { get; set; }
public ICollection<GarageRule> GarageRules { get; set; }
}
Or should I make each rule entity its own aggregate root? So then I can do performant queries such as garageRuleRepository.GetRulesByRuleSetAndGarage(RuleSet ruleSet, Garage garage)
. Otherwise I will end up which very large collections within my aggregate root that I cannot query correctly.