table User{
id string
name string
}
table Post{
id string
title string
content string
userId string
}

User의 id를 Post의 userId로 드래그 하면

서로 하나씩만 가질 수 있는지, 입장 바꿔서 생각해보기. 그렇게 많은 관계는 아님.
개념적 데이터모델링
논리적 데이터모델링
물리적 데이터모델링

유저와 게시글은 1:N 관계

User : PostLike - 1 : N
PostLike : Post - M : 1
User : Post - N : M
N:M 관계는 징검다리 같은 테이블 필요!
table User{
id uuid
name varchar(200) // 이름
age int
email varchar(200) // 이메일
phoneNumber char(11) // 전화번호
}
table UserSetting{
id uuid
alarm boolean // 알림 설정 유무
privateAgreement boolean // 개인정보 수집 동의
userId uuid
}
table Post{
id uuid
title varchar(200) // 제목
content longtext // 내용
userId uuid // 유저 id [fk]
}
table PostLike{
userId uuid
postId uuid
// pk : userId + postId
}
table PostBookmark{
id uuid // pk
title varchar(200)
extraContent varchar(200)
userId uuid
postId uuid
}
Ref: "User"."id" < "Post"."userId"
Ref: "User"."id" < "UserSetting"."userId"
Ref: "User"."id" < "PostLike"."userId"
Ref: "Post"."id" < "PostLike"."postId"
Ref: "User"."id" < "PostBookmark"."userId"
Ref: "Post"."id" < "PostBookmark"."postId"

📌 PostLike 테이블은 id가 없는데 어떻게 구분할까? -> userId와 postId를 합칩.
📖 https://www.velog.io 사이트에 대한 ERD 그려보기