Data Model ERD
Data Model ERD
1. 핵심 엔티티
users
merchants
slots
reservations
penalties
subscriptions
event_logs (운영/분석)
audit_logs (무결성/관리)
2. 관계(텍스트 ERD)
users (1) ---- (0..N) reservations
merchants (1) ---- (0..N) slots
slots (1) ---- (0..N) reservations
users (1) ---- (0..1) penalties
merchants (1) ---- (0..1) subscriptions
reservations (N) ---- (0..N) event_logs
* audit_logs는 모든 entity를 참조할 수 있음3. 필수 키/제약(요약)
reservations.userId FK -> users.userId
reservations.slotId FK -> slots.slotId
slots.merchantId FK -> merchants.merchantId
penalties.userId UNIQUE
subscriptions.merchantId UNIQUE
중요 제약:
Slot: 0 <= remainingQuantity <= totalQuantity
Reservation: 상태별 필드 조건(ADR-DS-006)
사용자 RESERVED 동시 1개: UNIQUE(userId) WHERE status=‘RESERVED’
4. 공개 웹 노출 모델
공개 웹은 slots 원본 테이블 직접 조회 금지
public_get_nearby_slots RPC 또는 공개 View를 통해서만 조회(ADR-W-011)