Which Concept for relations


Given Scenario:

Two types of DomainObjects like “Customer” and “Device” each device should be assigned to at least one customer.

What is the best way to implement this with eventstore?

Should Customer and Device have its own stream ? And how should the relation be represented by ?

I could imagine some kind of custom projections and custom streams like (CustomerDEviceStream) to keep track of the associations.

Especially if two customers could have a relation to the device? Is there a built in conecpt in get eventstore oversee ?

Many thanks in advance

You probably want a separate event stream for each, and either a LinkedToDevice { DeviceId: XYZ } event in the customer stream or a LinkedToCustomer { CustomerId: XYZ } event in the device stream. The latter will make it easier to enforce your “Device must be assigned to at least one customer” constraint.