How to determine which service keeps the relation to the other?
Suppose I have 3 (example) services (eg seperate microservices in my Docker cluster): Reseller Service - Our code is turned into whitelabel software. This is the service that owns the Reseller related data, like its ID, name, main brand, active modules etc. Creation and updating can only be done via the API to this service Distributor - This owns the data for distributors, like the name and logo Insurance - This owns the data for insurances, like the name and max amount We've now came across the following issue: Not every Reseller has all Distributors or Insurances. We need to config what distributors are active for a Reseller and what Insurances are active for a Reseller. This presents us (afaik) two routes we can take: Reseller Service with a Reseller table and pivot table reseller_distributor with an r_id and d_id. Distributor Service with a Distributor table and pivot table distributor_reseller with an d_id and r_id. There are good arguments to be made for both, how do we make a choice? Pro Distributor at Reseller: You config a Reseller, which is an important object, and you can do that in one location. Con: Now the Reseller service needs to know about all Things (at least their IDs). Con: If you want additional info from the pivot (like active_from) you now need to change the Reseller Service Pro Distributor at Reseller: The Reseller needs to know about a Distributor, Insurance, Example only once, in the pivot column. We're coming up with good arguments for both routes and we dont really think there is a bad solution*, but still we like to apply good practices :) * Apart from the ChatGPT solution: Create a new Microservice which only responsibility would be to store the relations between everything.

Suppose I have 3 (example) services (eg seperate microservices in my Docker cluster):
- Reseller Service - Our code is turned into whitelabel software. This is the service that owns the Reseller related data, like its ID, name, main brand, active modules etc. Creation and updating can only be done via the API to this service
- Distributor - This owns the data for distributors, like the name and logo
- Insurance - This owns the data for insurances, like the name and max amount
We've now came across the following issue: Not every Reseller has all Distributors or Insurances. We need to config what distributors are active for a Reseller and what Insurances are active for a Reseller.
This presents us (afaik) two routes we can take:
- Reseller Service with a
Reseller
table and pivot tablereseller_distributor
with anr_id
andd_id
. - Distributor Service with a
Distributor
table and pivot tabledistributor_reseller
with and_id
andr_id
.
There are good arguments to be made for both, how do we make a choice?
Pro Distributor at Reseller: You config a Reseller, which is an important object, and you can do that in one location.
Con: Now the Reseller service needs to know about all Things (at least their IDs).
Con: If you want additional info from the pivot (like active_from) you now need to change the Reseller Service
Pro Distributor at Reseller: The Reseller needs to know about a Distributor, Insurance, Example only once, in the pivot column.
We're coming up with good arguments for both routes and we dont really think there is a bad solution*, but still we like to apply good practices :)
* Apart from the ChatGPT solution: Create a new Microservice which only responsibility would be to store the relations between everything.