Domain Driven Design Series of Simple Consolidated Root Questions

I have a few (hopefully) simple questions about elementary roots in a domain driven project:

  • Is it possible to have an aggregated root as a property of another aggregated root?
  • Is it possible to have a given entity within two or more aggregate roots?

My last question is a little more in demand. I have a website with multiple entities that actually belong to the aggregated root "website". These are "News", "Products" and "Users". There is no table "Website" in the database, but "Website" seems to be a good placeholder for these three objects. How is this usually achieved?

Thanks!

+2


a source to share


1 answer


Do you have any site-wide consistency rules (across multiple news products and usesrs)? If not, these organizations (news, products, users) are good candidates to be cumulative roots.

The aggregate main function is to enforce consistency and boundary of transaction semantics.



To answer your questions:

  • Yes, this is fine as long as the specified aggregate root is not changed during any operation containing AR. This is due to consistency boundaries: operations spanning multiple aggregates are not guaranteed to give consistent results, so they should be avoided

  • No, an object (which is not an AR) can only be part of one aggregate.

+1


a source







All Articles