erDiagram
    USER {
        int id
        int company_id
        string name
        string email
        string role
    }

    COMPANY {
        int id
        string name
        string industry
        string size
    }

    CANDIDATE_PROFILE {
        int id
        int user_id
        string degree
        int years_experience
        string skill_tags
        string resume_url
    }

    JOB_POSITION {
        int id
        int company_id
        string title
        string level
        string required_skills
        string description
        string exam_policy_id
    }

    EXAM_POLICY {
        string id
        int total_questions
        float easy_ratio
        float medium_ratio
        float hard_ratio
        string type_ratio
    }

    QUESTION {
        int id
        string content
        string type
        string skill_tag
        int difficulty
        string source
        bool is_active
    }

    QUESTION_STATS {
        int question_id
        int used_count
        float avg_score
        float correct_rate
        float discrimination
        float feedback_score
        datetime last_used_at
    }

    EXAM_TEMPLATE {
        int id
        int job_id
        string policy_id
        string question_slots
    }

    EXAM_SESSION {
        int id
        int candidate_id
        int job_id
        int template_id
        datetime start_time
        datetime submit_time
        float total_score
        string status
    }

    ANSWER {
        int id
        int session_id
        int question_id
        string content
        float score
        float time_taken
    }

    QUESTION_FEEDBACK {
        int id
        int question_id
        int from_user_id
        int session_id
        int rating
        string comment
        datetime created_at
    }

    COMPANY ||--o{ USER : has
    USER ||--o{ CANDIDATE_PROFILE : has
    COMPANY ||--o{ JOB_POSITION : posts
    EXAM_POLICY ||--o{ JOB_POSITION : configures
    JOB_POSITION ||--o{ EXAM_TEMPLATE : uses
    EXAM_TEMPLATE ||--o{ EXAM_SESSION : instantiates
    USER ||--o{ EXAM_SESSION : takes
    EXAM_SESSION ||--o{ ANSWER : contains
    QUESTION ||--o{ ANSWER : answered_in
    QUESTION ||--|| QUESTION_STATS : stats
    QUESTION ||--o{ QUESTION_FEEDBACK : receives
    USER ||--o{ QUESTION_FEEDBACK : writes
