akuntansi-sia/database/ERD.md

1.9 KiB

ERD

erDiagram
    USERS {
        bigint id PK
        string name
        string email
        timestamp email_verified_at
        string password
        timestamp created_at
        timestamp updated_at
        string role
        string branch
    }

    BRANCHES {
        bigint id PK
        string name
        timestamp created_at
        timestamp updated_at
    }

    PRODUCTS {
        bigint id PK
        string name
        enum category
        integer purchase_price
        integer selling_price
        string image
        string branch
        timestamp created_at
        timestamp updated_at
    }

    STOCKS {
        bigint id PK
        bigint product_id FK
        string branch
        integer quantity
        string unit
        timestamp created_at
        timestamp updated_at
    }

    PURCHASES {
        bigint id PK
        date date
        string branch
        string item
        string quantity
        integer total_price
        bigint product_id FK
        timestamp created_at
        timestamp updated_at
    }

    SALES {
        bigint id PK
        date date
        string branch
        string item
        integer quantity
        integer total_price
        bigint product_id FK
        timestamp created_at
        timestamp updated_at
    }

    OPERATIONAL_COSTS {
        bigint id PK
        string branch
        date date
        string label
        integer amount
        timestamp created_at
        timestamp updated_at
    }

    USERS ||--o{ BRANCHES : "belongs_to (via branch name)"
    PRODUCTS ||--o{ BRANCHES : "belongs_to (via branch name)"
    STOCKS }o--|| PRODUCTS : "product_id"
    PURCHASES }o--|| PRODUCTS : "product_id"
    SALES }o--|| PRODUCTS : "product_id"

    BRANCHES ||--o{ STOCKS : "has"
    BRANCHES ||--o{ PURCHASES : "has"
    BRANCHES ||--o{ SALES : "has"
    BRANCHES ||--o{ OPERATIONAL_COSTS : "has"