Pagination and filtering are performed even if there is only one table, right?
So, I think the question is how to join tables between microservices.
I think people use microservices to avoid as much table joining as possible between microservices. If they cannot, perhaps the tables should not be shared in different microservices at all.
, . , , :
create table t_hotel (
id VARCHAR(40) not null,
name varchar(50) not null,
location varchar(50) not null,
CONSTRAINT pk_hotel PRIMARY KEY (id)
);
create table t_hotel_comment (
id VARCHAR(40) not null,
hotel_id varchar(40) not null,
content varchar(50) not null,
CONSTRAINT pk_hotel_comment PRIMARY KEY (id)
);
, , .
____________________________
| name | location | comments |
| foo | foooooo | 2 |
| bar | barrrrr | 3 |
----------------------------
, api:
, N + 1, t_hotel:
create table t_hotel (
id VARCHAR(40) not null,
name varchar(50) not null,
location varchar(50) not null,
comments numeric not null,
CONSTRAINT pk_hotel PRIMARY KEY (id)
);
, , HotelCommentedEvent
HotelCommentedEvent {
"comment_id": "id",
"hotel_id": "foo",
"content": "bar"
}
. .