사용한 홈페이지: https://www.erdcloud.com/

스크린샷 2025-12-03 오전 10.34.34.png

스크린샷 2025-12-03 오전 10.35.32.png

erDiagram
    %% ====================================
    %% Entity Definitions with All Fields
    %% ====================================

    User {
        string id PK
        string email UK
        string password
        string name
        UserType type
        string image
        int point
        datetime createdAt
        datetime updatedAt
        string gradeId FK
    }

    RefreshToken {
        string id PK
        string token UK
        string jti UK
        string userId FK
        datetime expiresAt
        datetime createdAt
    }

    Grade {
        string id PK
        string name
        int minAmount
        float rate
        datetime createdAt
        datetime updatedAt
    }

    Store {
        string id PK
        string name
        string content
        string address
        string detailAddress
        string phoneNumber
        string image
        datetime createdAt
        datetime updatedAt
        string userId FK,UK
    }

    Product {
        string id PK
        string name
        int price
        string content
        string image
        int discountRate
        datetime discountStartTime
        datetime discountEndTime
        boolean isSoldOut
        int salesCount
        int reviewsCount
        float reviewsRating
        datetime createdAt
        datetime updatedAt
        string storeId FK
        string categoryId FK
    }

    Category {
        string id PK
        string name UK
    }

    Stock {
        string id PK
        int quantity
        int reservedQuantity
        string productId FK
        int sizeId FK
    }

    Size {
        int id PK
        string en
        string ko
    }

    Cart {
        string id PK
        int quantity
        datetime createdAt
        datetime updatedAt
        string buyerId FK,UK
    }

    CartItem {
        string id PK
        int quantity
        datetime createdAt
        datetime updatedAt
        string cartId FK
        string productId FK
        int sizeId FK
    }

    Order {
        string id PK
        string name
        string phoneNumber
        string address
        OrderStatus status
        int subtotal
        int totalQuantity
        int usePoint
        datetime createdAt
        datetime expiresAt
        string buyerId FK
    }

    OrderItem {
        string id PK
        int price
        int quantity
        string orderId FK
        string productId FK
        int sizeId FK
    }

    Payment {
        string id PK
        int price
        PaymentStatus status
        PaymentProvider provider
        PaymentMethod method
        string impUid UK
        string pgTid
        string errorCode
        string errorMessage
        datetime approvedAt
        datetime failedAt
        datetime createdAt
        datetime updatedAt
        string orderId FK
    }

    Review {
        string id PK
        int rating
        string content
        datetime createdAt
        datetime updatedAt
        string userId FK
        string productId FK
        string orderItemId FK,UK
    }

    Inquiry {
        string id PK
        string title
        string content
        InquiryStatus status
        boolean isSecret
        datetime createdAt
        datetime updatedAt
        string userId FK
        string productId FK
    }

    Reply {
        string id PK
        string content
        datetime createdAt
        datetime updatedAt
        string userId FK
        string inquiryId FK,UK
    }

    StoreLike {
        string id PK
        datetime createdAt
        string userId FK
        string storeId FK
    }

    PointHistory {
        string id PK
        PointHistoryType type
        int amount
        datetime createdAt
        string userId FK
        string orderId FK
    }

    Notification {
        string id PK
        string content
        boolean isChecked
        datetime createdAt
        datetime updatedAt
        string userId FK
    }

    %% ====================================
    %% Relationships
    %% ====================================

    %% User & Auth
    User ||--o{ RefreshToken : has
    User ||--|| Grade : "belongs to"
    User ||--o| Store : owns
    User ||--o| Cart : has
    User ||--o{ Order : places
    User ||--o{ Review : writes
    User ||--o{ Inquiry : creates
    User ||--o{ Reply : answers
    User ||--o{ StoreLike : likes
    User ||--o{ Notification : receives
    User ||--o{ PointHistory : has

    %% Store & Product
    Store ||--o{ Product : sells
    Store ||--o{ StoreLike : "liked by"

    Product ||--|| Category : "belongs to"
    Product ||--o{ Stock : has
    Product ||--o{ CartItem : in
    Product ||--o{ OrderItem : ordered
    Product ||--o{ Review : reviewed
    Product ||--o{ Inquiry : inquired

    %% Size
    Size ||--o{ Stock : "used in"
    Size ||--o{ CartItem : "used in"
    Size ||--o{ OrderItem : "used in"

    %% Cart
    Cart ||--o{ CartItem : contains

    %% Order & Payment
    Order ||--o{ OrderItem : contains
    Order ||--o{ Payment : "paid by"
    Order ||--o{ PointHistory : "related to"

    %% Review
    OrderItem ||--o| Review : "reviewed by"

    %% Inquiry
    Inquiry ||--o| Reply : "answered by"