One to many relationship in separate database microservices

Viewed 298

In a microservice architechture with each microserice having it's own database, what is the recommended way of creating a one-to-many relationship between two microservices?

In my case I have two tables:

products

CREATE TABLE IF NOT EXISTS product.products (
  "id" UUID DEFAULT uuid_generate_v4(),
  ...
)

collections

CREATE TABLE IF NOT EXISTS collection.collections (
  "id" UUID DEFAULT uuid_generate_v4(),
  ...
)

What is recomennded between the following options?

  • a) products has field "collection" UUID
  • b) collections has field "products" UUID[]
  • c) both

Or is there another answer which better suits my use case, and if so, why?

0 Answers
Related