Let me tell you about the don, as I think he is leading you on the right path.
M-to-N relationships are natural, useful, and can be handled in DDD. If you need an M-to-N relationship, you don't need to try to convert it to (or most likely several) M-to-1 relationships. The Udi Dahan acticle provides a good example of how to handle M-to-N relationships between objects.
First determine which object should contain the list of identifiers of the other. Udi uses the sample job posting ( Job ) and message board ( JobBoard ). Since a job can exist without employment advice, and a job fee cannot exist without jobs, the JobBoard is selected as the aggregate root and will contain a List<Job> . This may seem like an M-to-1 relationship, but since each Job may be on the list for multiple JobBoard , it really is an M-to-N.
In your case, SocialAccount and Publisher I recommend something like this in C #:
public class Publisher { public int ID {get; private set;} private readonly IList<int> _AssignedSocialAccounts = new List<int>(); public IEnumerable<int> AssignedSocialAccounts { get { return this._AssignedSocialAccounts; } } public Publisher(int ID)
(This example uses domain encapsulation similar to Jimmy Bogard Wicked Domain Models .)
Note that I chose Publisher as the aggregate root, since a SocialAccount may exist on its own, but a Publisher does not make sense without the existence of SocialAccount .
Also note that I'm skipping unique identifiers, not links to the objects themselves. This is a common approach in DDD and allows lazy loading of related objects, although the trade-off is that you need to call the repository to get the objects when you want to access them.
This approach also means that you do not have all SocialAccount as a single listing. They are shared between different Publisher s. To get a list of all SocialAccount will need a separate request.
source share