
Table User {
id integer [primary key] // 유저 고유 ID
email varchar [unique] // 유저 이메일 (로그인 ID)
password varchar // 유저 비밀번호 (해시 형태 저장)
nickname varchar [unique] // 유저 별명
role varchar // 유저 권한(예: "USER", "ADMIN" 등)
status varchar // 유저 상태 (예: "ACTIVE", "SUSPENDED" 등)
created_at timestamp // 계정 생성일시
updated_at timestamp // 계정 정보 수정일시
deleted_at timestamp // 계정 삭제(탈퇴) 일시 (soft delete)
}
Table Book {
id integer [primary key] // 내부 DB에서 관리할 도서 PK
isbn varchar [unique] // 국제 표준 도서번호
title varchar // 책 제목
author varchar // 저자
publisher varchar // 출판사
cover_url varchar // 도서 표지 이미지 URL
published_date date // 출판일
created_at timestamp // 데이터 생성일시
updated_at timestamp // 데이터 수정일시
}
Table User_Book_Record {
id integer [primary key] // PK (유저-책 관계 ID)
user_id integer // FK → User (책을 읽은 유저 ID)
book_id integer // FK → Book (읽은 책 ID)
read_date date // 책을 읽은 날짜
created_at timestamp // 기록 생성일시
}
Table Review{
id integer [primary key] // 리뷰 고유 ID
user_book_id integer [unique] // FK → User_Book_Record (1:1) (읽은 책 ID)
title varchar // 리뷰 제목
content text // 리뷰 내용
rating integer // 별점 (1~5점)
created_at timestamp // 리뷰 작성날짜
updated_at timestamp // 리뷰 수정날짜
deleted_at timestamp // 리뷰 삭제날짜
}
Table Post {
id integer [primary key] // 게시글 PK
user_id integer // 작성자 ID
title varchar // 게시글 제목
content text // 게시글 내용
category varchar // 게시글 카테고리 ("독후감", "독서 모임 모집", "자유게시글" 등)
recruit_start_date date // (모집글 전용) 모집 시작 날짜
recruit_end_date date // (모집글 전용) 모집 종료 날짜
capacity integer // (모집글 전용) 모집 최대 인원
current_participants integer // (모집글 전용) 현재 신청된 인원
created_at timestamp // 게시글 생성일시
updated_at timestamp // 게시글 수정일시
}
Table Comment {
id integer [primary key] // 댓글 PK
user_id integer // 댓글 작성자 ID
post_id integer // 댓글이 달린 게시글 ID
parent_id integer // 대댓글의 부모 댓글 ID (자기 참조)
depth integer // 대댓글 개수 제한
content text // 댓글 내용
created_at timestamp // 댓글 생성일시
updated_at timestamp // 댓글 수정일시
deleted_at timestamp // 댓글 삭제일시 (soft delete)
}
Table Like {
id integer [primary key] // 좋아요 ID
user_id integer // FK → User (좋아요를 누른 사용자)
target_id integer // 좋아요 대상 ID (Post ID 또는 Comment ID)
target_type varchar // "POST" 또는 "COMMENT"
created_at datetime // 좋아요 누른 시간
}
Table ReadingClub {
id integer [primary key] // 독서 모임(클럽) PK
user_id integer // 모임 개설자(호스트) ID
title varchar // 모임 이름/주제
description text // 모임 설명
max_participants integer // 최대 참가자 수
created_at timestamp // 모임 생성일시
updated_at timestamp // 모임 수정일시
}
Table ReadingClubUser {
id integer [primary key] // 모임 가입 정보 PK
reading_club_id integer // 독서 모임 ID
user_id integer // 모임 참가자 ID
joined_at timestamp // 모임 참가일
}
Table ChatRoom {
id integer [primary key] // 채팅방 PK
name varchar // 채팅방 이름 (그룹일 경우)
reading_club_id integer [unique, null] // FK → ReadingClub, 그룹 채팅방일 경우 연결
is_group boolean // 채팅방 유형 (그룹/1:1 여부)
created_at timestamp // 채팅방 생성일시
updated_at timestamp // 채팅방 수정일시
}
Table ChatParticipant {
id integer [primary key] // 채팅 참여 정보 PK
chat_room_id integer // 어느 채팅방에 참여하는지
user_id integer // 참여자 ID
joined_at timestamp // 채팅 참여 시작일시
}
Table Message {
id integer [primary key] // 메시지 PK
chat_room_id integer // 어느 채팅방에 속한 메시지인지
user_id integer // 메시지 작성자
content text // 메시지 내용
created_at timestamp // 메시지 전송일시
}
Table Notification {
id integer [primary key] // 알림 PK
user_id integer // 알림 수신자
notification_type varchar // 알림 유형 (예: "NEW_COMMENT", "LIKE", "CLUB_NOTICE")
message varchar // 알림 내용
is_read boolean // 알림 읽음 상태
created_at timestamp // 알림 생성일시
}
// ------------------------------------------------------------
// 테이블 간 관계 정의 (References)
// ------------------------------------------------------------
// User_Book_Record - User (N:1)
Ref: User_Book_Record.user_id > User.id
// User_Book_Record - Book (N:1)
Ref: User_Book_Record.book_id > Book.id
// Review - User_Book_Record (1:1)
Ref: Review.user_book_id - User_Book_Record.id // [one-to-one]
// Post - User (N:1)
Ref: Post.user_id > User.id
// Comment - User (N:1), Comment - Post (N:1), Comment - Comment (자기 참조)
Ref: Comment.user_id > User.id
Ref: Comment.post_id > Post.id
Ref: Comment.parent_id > Comment.id
// PostLike - User (N:1), Like - Post 또는 Comment (다형성 구조)
Ref: Like.user_id > User.id
Ref: Like.target_id > Post.id // target_type이 "POST"일 때
Ref: Like.target_id > Comment.id // target_type이 "COMMENT"일 때
// ReadingClub - User (N:1) // 모임 개설자
Ref: ReadingClub.user_id > User.id
// ReadingClubUser - ReadingClub (N:1), ReadingClubUser - User (N:1)
Ref: ReadingClubUser.reading_club_id > ReadingClub.id
Ref: ReadingClubUser.user_id > User.id
// ChatRoom - ReadingClub (1:1)
Ref: ChatRoom.reading_club_id - ReadingClub.id // [one-to-one]
// ChatRoom, ChatParticipant, Message
Ref: ChatParticipant.chat_room_id > ChatRoom.id
Ref: ChatParticipant.user_id > User.id
Ref: Message.chat_room_id > ChatRoom.id
Ref: Message.user_id > User.id
// Notification - User
Ref: Notification.user_id > User.id