T
T
t800zippygod2021-02-23 23:57:39
Problem-Based Design
t800zippygod, 2021-02-23 23:57:39

How to properly implement relationships between DDD entities?

Hello everyone, I have a question. My domain entity has an array of other domains, which in turn refer to the parent. Thus the same relations at me are stored in . So, I see two problems here:
1) First, in my opinion, I'm violating the DRY principle - the relationships I have and in the database are stored and implemented at the domain level.
2) Secondly, I simply run into recursion when adding an entry to the database. Roughly speaking, when mapping (correlating the domain and the data stored in the database) of the domain, I start mapping the domains lying in it, and inside them the parent is mapped again. Haha, and all around!
The question is how to correctly implement this moment with related entities? Where are the relationships between them?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-02-24
@sergey-gornostaev

You are not breaking DRY, you are not building a bounded context, which is the basis of DDD. And the relationship must grow from the aggregate root, which obviously makes circular dependencies impossible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question