ERD - PIC-2-team/PIC-2-team-project GitHub Wiki
ERD
์ต์ด ์์ฑ: 2026-10-08 | ์ต์ข
์
๋ฐ์ดํธ: 2026-10-14
API Spec v1 ๋ฐ ADR-004(๊ธฐ์ ์คํ ํ์ ) ๊ธฐ๋ฐ์ผ๋ก ์ ๋ฉด ์ฌ์์ฑ
์ธ์ฆยท์ฌ์ฉ์
erDiagram
USER {
bigint id PK
string name
string email
string password "nullable: ์์
๊ฐ์
๊ณ์ "
string phone "nullable"
string publicCode "nullable: GUARDIANยทSUPPORT_WORKER๋ง, P- ๋๋ S- + 8์"
enum role "GUARDIAN | SUPPORT_WORKER | INSTITUTION"
datetime createdAt
}
CONSENT {
bigint id PK
bigint userId FK
boolean basicInfo
boolean sensitiveInfo
boolean caregiverShare
boolean marketing "๊ธฐ๋ณธ false"
string termsVersion
datetime agreedAt
}
REFRESH_TOKEN {
bigint id PK
bigint userId FK
string tokenHash
datetime expiresAt "30์ผ"
datetime revokedAt "nullable: ๋ก๊ทธ์์ยท๊ฐ์ ๋ง๋ฃ"
datetime createdAt
}
ORGANIZATION {
bigint id PK
bigint ownerId FK "INSTITUTION USER"
string name
string organizationCode "๊ณ ์ , AA-999 ํ์"
datetime createdAt
}
ORGANIZATION_MEMBER {
bigint id PK
bigint organizationId FK
bigint userId FK "SUPPORT_WORKER"
enum status "ACTIVE | INACTIVE"
datetime joinedAt
}
USER ||--|| CONSENT : ""
USER ||--o{ REFRESH_TOKEN : ""
USER ||--o| ORGANIZATION : "๊ธฐ๊ด๋ง"
ORGANIZATION ||--o{ ORGANIZATION_MEMBER : ""
USER ||--o{ ORGANIZATION_MEMBER : "์ง์์ฌ๋ง"
๋น์ฌ์ยท๋ณดํธ์ยท๋ฐฐ์
erDiagram
CARE_RECIPIENT {
bigint id PK
string careRecipientNumber "P-XXXXXXXX, ๊ณ ์ "
string name "์ต๋ 50์"
date birthDate
enum gender "FEMALE | MALE | NOT_SPECIFIED, nullable"
string disabilityGrade "nullable, ์ต๋ 20์"
string otherDisabilityType "nullable"
datetime latestRecordAt "nullable"
datetime createdAt
}
CARE_RECIPIENT_DISABILITY {
bigint id PK
bigint careRecipientId FK
enum disabilityType "INTELLECTUAL | AUTISM | OTHER"
}
CARE_GUARDIAN {
bigint id PK
bigint careRecipientId FK
bigint guardianId FK
enum type "PRIMARY | SECONDARY"
enum status "INVITED | READY | ACTIVE, nullable: SECONDARY๋ง"
string invitationToken "nullable: SECONDARY INVITED ์ํ"
datetime expiresAt "nullable"
datetime createdAt
}
ORGANIZATION_RECIPIENT_LINK {
bigint id PK
bigint organizationId FK
bigint careRecipientId FK
enum status "PENDING | ACCEPTED | REJECTED"
datetime createdAt
}
CARE_ASSIGNMENT {
bigint id PK
bigint organizationId FK
bigint careRecipientId FK
bigint supportWorkerId FK
string idempotencyKey "์ค๋ณต ๋ฐฐ์ ๋ฐฉ์ง"
date startDate
date endDate "nullable"
datetime endedAt "nullable: ์ค๋ ์ข
๋ฃ"
datetime createdAt
}
CARE_RECIPIENT ||--o{ CARE_RECIPIENT_DISABILITY : ""
CARE_RECIPIENT ||--o{ CARE_GUARDIAN : ""
CARE_RECIPIENT ||--o{ ORGANIZATION_RECIPIENT_LINK : ""
CARE_RECIPIENT ||--o{ CARE_ASSIGNMENT : ""
์ํ๊ธฐ๋กยท๋๋ด์ ๋ณด
erDiagram
DAILY_RECORD {
bigint id PK
bigint careRecipientId FK
bigint authorId FK
text content "์ต๋ 500์"
enum category "COMMUNICATION | LIFESTYLE | MEAL | PREFERENCE | CHALLENGING_BEHAVIOR | HEALTH | EMERGENCY | OTHER"
datetime recordedAt
boolean pinned "๊ธฐ๋ณธ false"
bigint recordRequestId FK "nullable"
datetime createdAt
datetime updatedAt
datetime deletedAt "nullable: soft delete, 30์ผ ๋ณต๊ตฌ ๊ฐ๋ฅ"
}
RECORD_MEDIA {
bigint id PK
bigint careRecipientId FK
bigint uploaderId FK
string fileName
enum mediaType "IMAGE | VIDEO | AUDIO"
bigint sizeBytes "์ต๋ 50MB"
string s3Key
datetime createdAt
}
RECORD_MEDIA_LINK {
bigint recordId FK
bigint mediaId FK
}
RECORD_REVISION {
bigint id PK
bigint recordId FK
bigint changedById FK
text content
enum category "DAILY_RECORD.category์ ๋์ผ"
datetime recordedAt
int revision
datetime changedAt
}
RECORD_SUGGESTION {
bigint id PK
bigint recordId FK
bigint suggestedById FK
text proposedContent
enum proposedCategory "DAILY_RECORD.category์ ๋์ผ"
text reason "nullable"
enum status "PENDING | APPROVED | REJECTED"
datetime createdAt
}
CARE_INFO {
bigint id PK
bigint careRecipientId FK
enum category "COMMUNICATION | PREFERENCE | LIFESTYLE | HEALTH_MEDICATION | PRECAUTION | EMERGENCY"
text content "์ต๋ 3000์, nullable"
datetime updatedAt "nullable"
}
DAILY_RECORD ||--o{ RECORD_MEDIA_LINK : ""
RECORD_MEDIA ||--o{ RECORD_MEDIA_LINK : ""
DAILY_RECORD ||--o{ RECORD_REVISION : ""
DAILY_RECORD ||--o{ RECORD_SUGGESTION : ""
CARE_RECIPIENT ||--o{ CARE_INFO : ""
์์ฒญยท์๋ฆผยท์ ๊ทผ ์ด๋ ฅ
erDiagram
INFORMATION_REQUEST {
bigint id PK
bigint careRecipientId FK
bigint requestedById FK "SUPPORT_WORKER"
text message "์ต๋ 1000์"
text reply "nullable"
enum status "SUBMITTED | FORWARDED | ANSWERED | CLOSED"
datetime createdAt
datetime updatedAt
}
RECORD_REQUEST {
bigint id PK
bigint organizationId FK
bigint careRecipientId FK
bigint supportWorkerId FK
string idempotencyKey
text message
bigint completedRecordId FK "nullable"
enum status "OPEN | COMPLETED | CANCELLED"
datetime createdAt
}
NOTIFICATION {
bigint id PK
bigint userId FK
enum type "RECORD_CREATED | RECORD_UPDATED | ASSIGNMENT_CHANGED | SUGGESTION_RECEIVED | SUGGESTION_DECIDED | INFORMATION_REQUEST_RECEIVED | RECORD_REQUEST_RECEIVED | RECORD_FORWARDED | ORGANIZATION_LINK_REQUESTED"
text message
boolean read "๊ธฐ๋ณธ false"
datetime createdAt
}
ACCESS_LOG {
bigint id PK
bigint actorId FK
bigint careRecipientId FK
enum action "READ | CREATE | UPDATE | DELETE"
string resourceType
bigint resourceId
datetime occurredAt
}
ํต์ฌ enum ์์ฝ
| ํ
์ด๋ธ |
ํ๋ |
๊ฐ |
USER |
role |
GUARDIAN | SUPPORT_WORKER | INSTITUTION |
CARE_RECIPIENT |
gender |
FEMALE | MALE | NOT_SPECIFIED |
CARE_RECIPIENT_DISABILITY |
disabilityType |
INTELLECTUAL | AUTISM | OTHER |
DAILY_RECORD |
category |
COMMUNICATION | LIFESTYLE | MEAL | PREFERENCE | CHALLENGING_BEHAVIOR | HEALTH | EMERGENCY | OTHER |
CARE_INFO |
category |
COMMUNICATION | PREFERENCE | LIFESTYLE | HEALTH_MEDICATION | PRECAUTION | EMERGENCY |
CARE_GUARDIAN |
status |
INVITED | READY | ACTIVE |
CARE_ASSIGNMENT |
โ |
startDate/endDate๋ก ๊ธฐ๊ฐ ๊ด๋ฆฌ (N:M temporal) |
RECORD_SUGGESTION |
status |
PENDING | APPROVED | REJECTED |
INFORMATION_REQUEST |
status |
SUBMITTED | FORWARDED | ANSWERED | CLOSED |
RECORD_REQUEST |
status |
OPEN | COMPLETED | CANCELLED |
์ด์ ๋ฏธ๊ฒฐ ์ฌํญ โ ํด์
| ํญ๋ชฉ |
๊ฒฐ์ |
| ๋๋ด ์ ๊ณต์ โ ํผ๋๋ด์ ๊ด๊ณ 1:N vs N:M |
CARE_ASSIGNMENT์ startDate/endDate๋ก N:M temporal ๊ด๋ฆฌ |
CARE_INFO.content JSON vs ๋ถ๋ฆฌ |
text ๋จ์ผ ์ปฌ๋ผ (์นดํ
๊ณ ๋ฆฌ 6๊ฐ ํ์ผ๋ก ๋ถ๋ฆฌ) |
| ์ด๋ฏธ์ง/ํ์ผ ์ฒจ๋ถ |
RECORD_MEDIA ํ
์ด๋ธ ์ถ๊ฐ, AWS S3 ์ ์ฅ (ADR-004) |
์ฐธ๊ณ
USER.publicCode: P- ์ ๋์ฌ๋ GUARDIAN, S- ์ ๋์ฌ๋ SUPPORT_WORKER
ORGANIZATION.organizationCode: AA-999 ํ์ (์๋ฌธ 2์ + ์ซ์ 3์)
REFRESH_TOKEN.tokenHash: ์๋ฌธ ํ ํฐ์ ํด์ํ์ฌ ์ ์ฅ
DAILY_RECORD ์ญ์ ๋ soft delete โ deletedAt ๊ธฐ๋ก ํ 30์ผ ์ด๋ด ๋ณต๊ตฌ ๊ฐ๋ฅ
RECORD_MEDIA๋ ๊ธฐ๋ก์ ์ฒจ๋ถ๋๊ธฐ ์ ๋จ๊ณ(์
๋ก๋ ์งํ)์๋ ๋
๋ฆฝ ์กด์ฌ ๊ฐ๋ฅ