I have the following domain modelling problem where I seem to end up either crossing consistency boundaries or creating a huge aggregate. Can someone help me break it up?
There are two job types JobA
, JobB
. JobA
is composed of tasks TaskA
. JobB
is composed of tasks TaskB
. JobA
and JobB
are unrelated. The only thing is common between them is that they both need an equipment resource. I had originally wanted to create 5 aggregate roots which may reference each other - JobA
will reference TaskA
and so on.
I can possibly put a job and its tasks in one aggregate. That comes at an expense of introducing other overhead as tasks themselves are complex creatures. However, the following constraints prevent me from using either model.
- A job cannot be marked complete if any task is still incomplete. This check causes transactions to cross aggregate boundaries (e.g.,
TaskA
andJobA
). - An equipment cannot be assigned to more than 1 job. This check will span across both job aggregates.
- Equipment has to be released before job can be marked complete. This transaction will cross equipment and job aggregates.
Having a single aggregate will put all transactions inside the boundary but that will make the aggregate impossibly large. Is there a different model hidden in all this that I am missing?