---
# System prepended metadata

title: ERD's

---

# ERD's

#### TODO:
- insert-only flow for `user` table

<!--
<style>
pre.mermaid {
    overflow-x: auto !important;
}
svg[id^='mermaid-'] {
    min-width: 200% !important;
}
</style>
-->

```mermaid
%%{init: {
    "er": {
    }
}}%%

erDiagram
    user {
        serial user_id
        varchar email
        varchar password
        varchar phone_number
        int company_id
        int role_id
        int login_attempts
        bool is_blocked
        timestamp registered_at
        varchar language_code
        int session_timeout
    }

    jwt_auth {
        serial jwt_auth_id
        int user_id
        varchar refresh_jwt
        timestamp created_at
    }
    user ||--|{ jwt_auth: user_id

    confirm_code {
        int auth_code_id
        int user_id
        int failed_attempts
        varchar code
        timestamp created_at
    }
    user }|--o| confirm_code: user_id

    company {
        serial company_id
        timestamp created_at
        varchar name
        bool is_blocked
        int company_user_id
    }
    company ||--|{ user: company_id
    user ||--|| company: company_user_id

    role {
        serial role_id
        varchar name
    }
    role ||--|{ user: user_id

    captcha {
        serial captcha_id
        int user_id
        text image
    }
    user |o--|{ captcha: user_id

    helpdesk_user {
        serial helpdesk_user_id
        varchar user_identifier
    }
    
    sent_email_user {
        int sent_email_id
        int user_id
    }

    sent_email {
        serial sent_email_id
        int user_id
        varchar template_name
        varchar template_data
    }

    sent_email ||--|{ sent_email_user: sent_email_id
    sent_email ||--|{ user: user_id
```