Domain-driven project: how to handle a conceptually large aggregate root?

I am trying to simulate a very simple domain that has a conceptual (one) PARENT โ†’ (many) BABY. The problem is that the number of children in a relationship can be in the millions.

I am trying to build a shared array that will allow me to โ€œputโ€ (update or insert, if not exist) one child at a time. However, updated values โ€‹โ€‹must be pre-checked by the parent.

What patterns can I use for this? I have currently reviewed the following:

PARENT as an aggregate root

  • + The check is simple, since access to the daughters is through the parent
  • - Necessary, as it may be necessary to extract millions of children in order to update only one
  • +/- Can I do lazy loading? I read an article highlighting that this is an anti-DDD pattern due to consistency.

CHILD as a cumulative root

  • + Perform as soon as receiving data for updating
  • -Validation, because it is nontrivial, either the parent must be the root entity, or the root must be externally provided to the parent for verification. Both options cause problems:
    • Since the update is a โ€œtaggedโ€ style, the first parameter makes it difficult to create a child (if I implement the creation of the store in the find (id) method, then I donโ€™t have the necessary information to build the child and if I put it into the service by calling the repository, then I have no way to access parent information, as this is not a cumulative root).
    • , .. , .

  • +/- , .. ?
+4
1

, (AR). . , , . AR.

"" - , AR, , AR. , , , . CRUD.

, , , ?

+1

Source: https://habr.com/ru/post/1541750/


All Articles