D
D
dauren102022-04-01 09:37:34
Database
dauren10, 2022-04-01 09:37:34

Foreign key in microservices?

Good afternoon,
if there are 2 microservices with their own databases
user_db --table users(id,email)
chat_db --table chat(id,user_id)
It turns out that communication microservices do not use other relationships?
Since there will be a bunch of separate services and databases (different business entities) but containing the user_id column

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nApoBo3, 2022-04-01
@dauren10

1. Each microservice is a separately completed application. Those. user_id for chat is exactly the same field as, for example, user_message or message_utcdatetime. It does not bear any "binding" load.
2. Microservice should not have problems within itself if the user_id is not correct.
3. Yes, you will have separate services that have a user_id field that is not controlled at the database integrity level. You should ensure its integrity by other mechanisms. For example, completely refuse to control the integrity of this field, by and large, what difference does it make to you in the chat service, what exactly is written in this user_id.

L
Larisa .•º, 2022-04-01
@barolina

For data integrity, you can try using FDW

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question