Skip to content

Checkout Application ER Diagram

erDiagram
    COUPON_CODE {
        int id PK
        string code
        text description
        decimal discount_percent
        decimal money_value_off
        int total_issues
        int coupon_limit_per_customer
        int used_count
        int total_used
        datetime start_at
        datetime end_at
        decimal min_purchase
        bool is_active
        datetime created_at
        datetime updated_at
    }
    COUPON_CLAIM {
        int id PK
        int code_id FK
        int user_id FK
        bool is_claimed
        datetime claimed_at
    }
    APPLY_COUPON {
        int id PK
        int applied_coupon_id FK
        int shop_id FK
        int user_id FK
        decimal total_purchased
        decimal discounted_amount
        decimal grand_total
        bool has_applied
        datetime applied_at
    }
    PRODUCT_PURCHASED {
        int id PK
        int user_id FK
        int applied_coupon_id FK
        decimal total_purchased
        decimal discounted_amount
        decimal grand_total
        bool has_purchased_succeed
        datetime purchased_at
    }
    PURCHASED_CART_ITEM {
        int id PK
        int purchased_product_id FK
        int cart_item_id FK
        bool status
        datetime created_at
        datetime updated_at
        string order_id
    }

    COUPON_CODE ||--o{ COUPON_CLAIM : "is linked to"
    COUPON_CLAIM ||--o{ APPLY_COUPON : "applies"
    APPLY_COUPON ||--o{ PRODUCT_PURCHASED : "is used for"
    PRODUCT_PURCHASED ||--o{ PURCHASED_CART_ITEM : "contains"