Skip to content

Er Diagram of Chat Application


Below is the Entity-Relationship Diagram for the User, Vendor, Chat, and Messages models.

erDiagram
    User {
        int id PK
        string email
        string phone
        boolean has_initial_profile
        string photo
        TEXT address
        int gender_id FK
        int country_id FK
        DATE birthday
        DATETIME created_at
        DATETIME updated_at
    }

    Vendor {
        int id
        string company_name
        int user_id FK
        string company_name
        string telephone
        date company_created_at
        string company_address
        datetime created_at
        datetime updated_at
    }

    Chat {
        int id
        int vendor_id FK
        int user_id FK
        datetime created_at
        datetime updated_at
    }

    Message {
        uuid id
        int chat_id(one-to-one) FK
        int user_id(sender) FK
        int user_id(Receiver) FK
        string message_type
        text content
        file image
        file image
        file image
        boolean is_read
        datetime created_at
        datetime updated_at
    }

    User ||--o{ Vendor : "is associated with"
    Vendor ||--o{ Chat : "participates in"
    User ||--o{ Chat : "initiates"
    Chat ||--o{ Message : "contains"
    User ||--o{ Message : "sends and receives"