이번 프로젝트는 가계부(Account Book) 시스템을 구축하는 것이 목표입니다. 사용자(User), 계좌(Account), 거래 내역(Transaction History)을 관리하고, 추가로 수입/지출 분석(Analysis) 및 알림(Notification) 기능을 제공합니다.
2️⃣ 데이터베이스 테이블 설계
📖 테이블 설명
테이블 이름설명
users
서비스 사용자 정보를 저장합니다.
accounts
사용자가 보유한 계좌 정보를 저장합니다.
transaction_history
계좌별 거래 내역을 저장합니다.
analysis
수입과 지출 내역을 분석하고 결과를 저장합니다.
notifications
사용자 알림을 관리합니다.
🔗 테이블 간 관계 (Relation)
users 1:N accounts (한 사용자는 여러 계좌를 가질 수 있음)
accounts 1:N transaction_history (한 계좌는 여러 거래 내역을 가질 수 있음)
users 1:N analysis (한 사용자는 여러 분석 요청 가능)
users 1:N notifications (한 사용자는 여러 알림을 받을 수 있음)
3️⃣ 테이블 상세 필드 설계
🗂️ users
필드명타입설명
id
INT (PK)
Primary Key, Auto Increment
email
VARCHAR
이메일 (Unique)
password
VARCHAR
비밀번호
nickname
VARCHAR
닉네임
name
VARCHAR
이름
phone_number
VARCHAR
전화번호
last_login
DATETIME
마지막 로그인
is_staff
BOOLEAN
스태프 여부 (기본: False)
is_admin
BOOLEAN
관리자 여부 (기본: False)
is_active
BOOLEAN
계정 활성화 여부 (기본: True)
🗂️ accounts
필드명타입설명
id
INT (PK)
Primary Key, Auto Increment
user_id
INT (FK)
사용자 ID (users 테이블 참조)
account_number
VARCHAR
계좌번호 (Unique)
bank_code
VARCHAR
은행 코드
account_type
VARCHAR
계좌 종류
balance
DECIMAL(15,2)
잔액
🗂️ transaction_history
필드명타입설명
id
INT (PK)
Primary Key, Auto Increment
account_id
INT (FK)
계좌 ID (accounts 테이블 참조)
transaction_amount
DECIMAL(15,2)
거래 금액
post_transaction_amount
DECIMAL(15,2)
거래 후 잔액
transaction_details
VARCHAR
거래 상세 내역
transaction_type
ENUM
입출금 타입 (입금/출금)
transaction_method
ENUM
거래 방법 (현금, 이체, 카드 결제 등)
transaction_timestamp
DATETIME
거래 일시 (기본값: 현재시간)
🗂️ analysis
필드명타입설명
id
INT (PK)
Primary Key, Auto Increment
user_id
INT (FK)
사용자 ID (users 테이블 참조)
analysis_target
ENUM
분석 대상 (수입/지출)
analysis_period
ENUM
분석 기간 (일간/주간/월간/연간)
start_date
DATE
분석 시작 날짜
end_date
DATE
분석 종료 날짜
description
TEXT
설명
result_image
VARCHAR
분석 결과 이미지
created_at
DATETIME
생성 날짜
updated_at
DATETIME
업데이트 날짜
🗂️ notifications
필드명타입설명
id
INT (PK)
Primary Key, Auto Increment
user_id
INT (FK)
사용자 ID (users 테이블 참조)
message
TEXT
메시지 내용
is_read
BOOLEAN
읽음 여부 (기본: False)
created_at
DATETIME
생성 날짜
4️⃣ ERD 다이어그램 (Mermaid)
erDiagram
users {
int id PK "Primary Key, Auto Increment"
varchar email "이메일 (Unique)"
varchar password "비밀번호"
varchar nickname "닉네임"
varchar name "이름"
varchar phone_number "전화번호"
datetime last_login "마지막 로그인"
boolean is_staff "스태프 여부 (Default: False)"
boolean is_admin "관리자 여부 (Default: False)"
boolean is_active "계정 활성화 여부 (Default: True)"
}
accounts {
int id PK "Primary Key, Auto Increment"
int user_id FK "Foreign Key: users.id"
varchar account_number "계좌번호 (Unique)"
varchar bank_code "은행 코드"
varchar account_type "계좌 종류"
decimal balance "잔액"
}
transaction_history {
int id PK "Primary Key, Auto Increment"
int account_id FK "Foreign Key: accounts.id"
decimal transaction_amount "거래 금액"
decimal post_transaction_amount "거래 후 잔액"
varchar transaction_details "거래 상세 내역"
enum transaction_type "입출금 타입 (입금/출금)"
enum transaction_method "거래 방법 (현금, 계좌 이체, 자동 이체, 카드 결제)"
datetime transaction_timestamp "거래 일시"
}
analysis {
int id PK "Primary Key, Auto Increment"
int user_id FK "Foreign Key: users.id"
enum analysis_target "분석 대상 (수입/지출)"
enum analysis_period "분석 기간 (일간/주간/월간/연간)"
date start_date "분석 시작 날짜"
date end_date "분석 종료 날짜"
text description "설명"
varchar result_image "분석 결과 이미지"
datetime created_at "생성 날짜"
datetime updated_at "업데이트 날짜"
}
notifications {
int id PK "Primary Key, Auto Increment"
int user_id FK "Foreign Key: users.id"
text message "메시지 내용"
boolean is_read "읽음 여부 (Default: False)"
datetime created_at "생성 날짜"
}
users ||--o{ accounts : has
accounts ||--o{ transaction_history : has
users ||--o{ analysis : has
users ||--o{ notifications : has