TUTORIAL

이커머스 DB 설계 단계별 가이드

쇼핑몰 데이터베이스 설계를 단계별로 배웁니다. 회원, 상품, 주문, 결제 테이블 설계부터 ERD 작성까지 완전 정복합니다.

럿지 AI 팀
2025-01-11
12
이커머스 DB 설계 단계
1

요구분석

2

ERD설계

3

정규화

4

구현

핵심 테이블 구조

users

id, email, name, password

products

id, name, price, stock

orders

id, user_id, total, status

order_items

order_id, product_id, qty

categories

id, name, parent_id

reviews

id, user_id, product_id, rating

관계 설계

1:N
User - Order
한 회원이 여러 주문
1:N
Order - OrderItem
한 주문에 여러 상품
N:1
Product - Category
여러 상품이 한 카테고리
1:N
Product - Review
한 상품에 여러 리뷰

Orders 테이블 SQL

CREATE TABLE orders (
  id BIGINT AUTO_INCREMENT PRIMARY KEY,
  user_id BIGINT NOT NULL,
  total DECIMAL(12,2) NOT NULL,
  status ENUM('pending','paid','shipped') DEFAULT 'pending',
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (user_id) REFERENCES users(id)
);

설계 시 고려사항

재고 관리 (동시성)
결제 상태 관리
배송 추적 정보
쿠폰/할인 시스템

관련 태그

#이커머스
#Database
#ERD
#테이블설계
#SQL