데이터베이스 ERD & 스키마
MariaDB 12.2.2 기준 · 총 23개 테이블 · 실제 DB에서 추출 (2026-02-19)
1. 테이블 관계도 (ERD)
┌─────────────────────────────────────────────────────────────────────┐
│ DOMAIN: Product │
│ │
│ ┌──────────┐ ┌──────────────────┐ ┌───────────────┐ │
│ │ products │────<│ product_mappings │>────│ sales_channels│ │
│ └────┬─────┘ └──────────────────┘ └───────────────┘ │
│ │ │
│ │ (brand_id, category_id, color_id, unit_id) │
│ └──────────> common_codes │
└─────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────┐
│ DOMAIN: Inventory │
│ │
│ products ──1:1──> ┌───────────┐ ──1:N──> ┌─────────────────────┐ │
│ │ inventory │ │inventory_allocations│ │
│ └─────┬─────┘ └─────────────────────┘ │
│ │ ▲ │
│ │ 1:N │ │
│ ▼ sales_channels │
│ ┌───────────┐ │
│ │stock_logs │ │
│ └───────────┘ │
│ │
│ ┌─────────────┐ ──1:N──> ┌──────────────────┐ │
│ │ stock_takes │ │ stock_take_items │──> products │
│ └─────────────┘ └──────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────┐
│ DOMAIN: Order │
│ │
│ sales_channels ──1:N──> ┌────────┐ ──1:N──> ┌─────────────┐ │
│ │ orders │ │ order_items │ │
│ └────┬───┘ └──────┬──────┘ │
│ │ │ │
│ │ 1:N └──> products │
│ ▼ │
│ ┌─────────────────┐ │
│ │ return_requests │──> products │
│ └─────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────┐
│ DOMAIN: Purchasing │
│ │
│ ┌───────────┐ ──1:N──> ┌─────────────────┐ ──1:N──> │
│ │ suppliers │ │ purchase_orders │ │ │
│ └───────────┘ └─────────────────┘ │ │
│ ┌───────┴──────────┐ │
│ │purchase_order │ │
│ │ _items │ │
│ └──────────────────┘ │
│ │ │
│ └──> products │
└─────────────────────────────────────────────────────────────────────┘
2. 도메인별 테이블 상세
2.1 Product 도메인
products (상품 마스터)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| code |
VARCHAR(255) |
UNI |
상품코드 |
| name |
VARCHAR(255) |
|
상품명 |
| price_in |
DECIMAL(10,2) |
|
입고가 (기본 0.00) |
| price_out |
DECIMAL(10,2) |
|
출고가 (기본 0.00) |
| safety_stock |
INT |
|
안전재고 (기본 10) |
| is_active |
TINYINT(1) |
|
활성 여부 (기본 1) |
| brand_id |
BIGINT UNSIGNED |
FK → common_codes |
브랜드 |
| category_id |
BIGINT UNSIGNED |
FK → common_codes |
카테고리 |
| color_id |
BIGINT UNSIGNED |
FK → common_codes |
색상 |
| unit_id |
BIGINT UNSIGNED |
FK → common_codes |
단위 |
product_mappings (채널별 SKU 매핑)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| product_id |
BIGINT UNSIGNED |
FK → products |
상품 |
| sales_channel_id |
BIGINT UNSIGNED |
FK → sales_channels |
판매채널 |
| channel_sku |
VARCHAR(255) |
IDX |
채널 전용 SKU |
sales_channels (판매 채널)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| code |
VARCHAR(255) |
UNI |
채널 코드 |
| name |
VARCHAR(255) |
|
채널명 (미쯔노, 센스매니아, 지니) |
| api_key |
TEXT |
|
API 인증 키 (암호화) |
| api_secret |
TEXT |
|
API 시크릿 |
| is_active |
TINYINT(1) |
|
활성 여부 |
common_codes (공통 코드)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| group |
VARCHAR(255) |
IDX |
코드 그룹 (brand, category, color, unit) |
| code |
VARCHAR(255) |
IDX |
코드값 |
| name |
VARCHAR(255) |
|
표시명 |
| sort_order |
INT |
|
정렬 순서 |
2.2 Inventory 도메인
inventory (재고)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| product_id |
BIGINT UNSIGNED |
FK(UNI) → products |
1상품 = 1재고 |
| quantity |
INT |
|
실물 재고 수량 |
| location |
VARCHAR(255) |
|
보관 위치 |
inventory_allocations (채널별 재고 할당)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| inventory_id |
BIGINT UNSIGNED |
FK → inventory |
재고 |
| sales_channel_id |
BIGINT UNSIGNED |
FK → sales_channels |
채널 |
| allocated_qty |
INT |
|
할당 수량 |
| reserved_qty |
INT |
|
예약 수량 (주문 대기) |
stock_logs (재고 이력)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| inventory_id |
BIGINT UNSIGNED |
FK → inventory |
재고 |
| type |
ENUM('IN','OUT','ADJUST','ALLOCATE') |
|
이력 유형 |
| quantity |
INT |
|
변동 수량 |
| reason |
VARCHAR(255) |
|
사유 |
| user_id |
BIGINT UNSIGNED |
FK → users |
처리자 |
stock_takes / stock_take_items (재고 실사)
- stock_takes: 실사 마스터 (name, status: Draft/InProgress/Completed, note)
- stock_take_items: 실사 상세 (product_id, expected_qty, counted_qty, difference)
2.3 Order 도메인
orders (주문)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| order_number |
VARCHAR(255) |
UNI |
주문번호 |
| sales_channel_id |
BIGINT UNSIGNED |
FK → sales_channels |
채널 |
| channel_order_id |
VARCHAR(255) |
IDX |
외부 채널 주문 ID |
| status |
INT |
|
상태 (0:입금전, 1:입금완료, 2:상품준비, 3:발송완료, 9:발송준비, 88:취소) |
| total_amount |
DECIMAL(15,2) |
|
결제 금액 |
| recipient_name |
VARCHAR(255) |
|
수령인 |
| recipient_phone |
VARCHAR(255) |
|
연락처 |
| shipping_address |
TEXT |
|
배송지 |
| tracking_number |
VARCHAR(255) |
|
송장번호 |
order_items (주문 상세)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| order_id |
BIGINT UNSIGNED |
FK → orders |
주문 |
| product_id |
BIGINT UNSIGNED |
FK → products |
상품 |
| quantity |
INT |
|
수량 |
| unit_price |
DECIMAL(15,2) |
|
단가 |
return_requests (반품 요청)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| order_id |
BIGINT UNSIGNED |
FK → orders |
원 주문 |
| product_id |
BIGINT UNSIGNED |
FK → products |
반품 상품 |
| quantity |
INT |
|
반품 수량 |
| reason |
VARCHAR(255) |
|
반품 사유 |
| status |
VARCHAR(255) |
|
상태 (Requested/Approved/Completed/Rejected) |
| resolution |
VARCHAR(255) |
|
처리 결과 |
2.4 Purchasing 도메인
suppliers (공급업체)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| name |
VARCHAR(255) |
|
업체명 |
| contact_name |
VARCHAR(255) |
|
담당자 |
| email |
VARCHAR(255) |
|
이메일 |
| phone |
VARCHAR(255) |
|
연락처 |
| address |
TEXT |
|
주소 |
| is_active |
TINYINT(1) |
|
활성 여부 |
purchase_orders (구매 발주)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| po_number |
VARCHAR(255) |
UNI |
발주번호 |
| supplier_id |
BIGINT UNSIGNED |
FK → suppliers |
공급업체 |
| status |
VARCHAR(255) |
|
Draft/Ordered/Received/Cancelled |
| total_amount |
DECIMAL(10,2) |
|
총액 |
| order_date |
DATE |
|
발주일 |
| expected_date |
DATE |
|
입고 예정일 |
| note |
TEXT |
|
비고 |
purchase_order_items (발주 상세)
| Field |
Type |
Key |
설명 |
| id |
BIGINT UNSIGNED |
PK |
|
| purchase_order_id |
BIGINT UNSIGNED |
FK → purchase_orders |
발주서 |
| product_id |
BIGINT UNSIGNED |
FK → products |
상품 |
| quantity |
INT |
|
발주 수량 |
| unit_price |
DECIMAL(10,2) |
|
단가 |
| received_qty |
INT |
|
입고 수량 (기본 0) |
2.5 시스템 테이블
| 테이블 |
용도 |
| users |
사용자 계정 |
| permissions / roles / role_has_permissions / model_has_* |
RBAC 권한 (spatie/permission) |
| settings |
시스템 설정 (key-value) |
| sessions |
세션 저장 |
| notifications |
알림 |
| personal_access_tokens |
API 토큰 (Sanctum) |
| password_reset_tokens |
비밀번호 재설정 |
| cache / cache_locks |
캐시 |
| jobs / job_batches / failed_jobs |
Queue 작업 |