Relationships Across Microservices


I have two microservices, lets call them “accounts” and “posts”

The “accounts-service” has it’s own database and handles “users” and “organizations”. Users can be a member of one or more organization.

The “posts-service” also has it’s own database and handles “posts” and “comments”. Both posts and comments have a creator which references a user id. Comments belong to a post. Posts belong to an organization by referencing an organization id.

I know how to setup the relationships between things in the same service, but I don’t know the best way to set up the relationships between resources in different services.

For instance, should a post have an attribute for “organizationId” or should it have a relationship for “organization”? If it should be under relationships, how to I do things like compound documents where a client asks for a post to include the organization (I don’t really want my microservices to be talking to eachother that much…but maybe I need to)?