I'm struggling to understand how to model my problem:
- A Company can have many Teams.
- Each Team must have a unique name per Company.
- Reports for a particular Team must be retrievable, along with a list of all reports for a Company.
Just now, I have 3 Bounded Contexts's - Company, Team and Report. I believe I should move Team inside Company to enforce my unique name invariant - however, as I understand it:
"Nothing outside the Aggregate boundary can hold a reference to anything inside, except to the root Entity".
If I can only reference an AR from my Report AR, I cannot store which Team my report belongs to - just the company.
I have considered that Team may exist as it's own BC and also within the Company BC. Creation of a Team would then only happen from within the Company BC as an Entity. Here, the naming and invariant enforcement of that Team name can be ensured. The Team BC would then still exist and a Report can still hold reference to the TeamId from the Report AR. However, this would result in duplication of TeamId and TeamName - both within the Company BC and Team BC.
Does this approach sound ok, or am I missing something?
I'm confused if I have 3 BC's that should be 2 BC's, or missing a Team Entity concept within Company BC.
Maybe I'm confusing Bounded Contexts I only have/need Aggregate Roots - I'm not sure!
Gulp, help!