✅ ERD Cloud에서 FK(연관관계) 설정 여부
즉, 각 서비스는 FK 값을 저장하고, 다른 서비스에서 해당 ID를 기반으로 데이터 조회만 하면 된다.
CREATE TABLE attendees (
id BIGINT PRIMARY KEY,
meeting_id BIGINT,
user_id BIGINT,
FOREIGN KEY (meeting_id) REFERENCES meetings(id),
FOREIGN KEY (user_id) REFERENCES users(id)
);
attendees 테이블이meetings와 users의 DB를 참조해야 함 → 서로 다른 서비스의 DB를 직접 연결하면 안 됨!CREATE TABLE attendees (
id BIGINT PRIMARY KEY,
meeting_id BIGINT, -- 모임 ID (Meeting Service에서 관리)
user_id BIGINT, -- 유저 ID (User Service에서 관리)
joined_at TIMESTAMP
);
meeting_id와 user_id를 그냥 숫자 값으로 저장1️⃣ API 호출 방식 (동기)
Meeting Service에서 참석자(user_id) 목록을 가져온다.User Service의 API를 호출하여 해당 유저 정보를 조회.GET /users?ids=101,102,103
2️⃣ 이벤트 기반 방식 (비동기)
User Service에서 유저 정보가 변경될 때(USER_UPDATED 이벤트) Meeting Service가 이를 구독하여 업데이트.