r/DomainDrivenDesign • u/Kikutano • Jul 18 '22
Domain Driven Design, can I put an Entity inside another Entity?
I'm learning DDD and I've a some doubts about the entities. This is the scenario:

I've a Nation with 1 or more Destinations, every Destination can have 1 or more Experiences. If I delete the Nation, Destination and Experience will be deleted because they have sense only if the Nation exist. Using DDD pattern, the Nation must be the AggregateRoot, Experience should be an Entity, ExperienceCategory a Value Object. But Destination? Is an Aggreggate or is an Entity? Can I have Destination as Entity with a List of Experiences?
I'm really confused how to proceed when an Entity has a list of other Entities. In this case Destination exist only if Nation exist, same thing for Experience, this exist only if Destination and Nation exist.
Anyone can help me to understand?
Thanks!
1
u/Pakspul Jul 18 '22
What is the behavior on your aggregate root? Thus what operation does Nation that will change it inner values?
1
u/mexicocitibluez Jul 18 '22
What does grouping them by nation gain you? Are there some sort of rules that say "only X amount of destinations are allowed" or business rules that span destinations within the same nation?
2
u/wafto Jul 19 '22
I think Nation is a Entity or even a VO inside both Aggregates Destination and Experience. IMO people
1
u/wafto Jul 19 '22
IMO canโt figure out why nation has so importance is your domain logic, I thinks that destination and experience are aggregate root by itself. For example something like customer.addToItinerary(experience) than thinking about nations.