@startuml erd
skinparam Linetype ortho
skinparam classFontSize 20
scale 1800 * 1800
hide circle

entity user {
    *<u>user_id</u>: <<uuid>>
    avatar_id: <<uuid>> (FK file)
    ---
    *name: varchar(255)
    *user_level: <<enum UserLevel>>
    *user_status <<enum UserStatus>>
    *email VARCHAR(45)
    *created_at: timestamp
    *edited_at: timestamp
    deleted_at: timestamp
}

entity timesheet {
    *<u>timesheet_id</u>: <<uuid>>
    ---
    *user_id: <<uuid>>
    *company_id: <<uuid>>
    *start_date: date
    *end_date: date
    *worked_hours: int
    *worked_minutes: int
    *is_editable: boolean
    *created_at: timestamp
    *edited_at: timestamp
    deleted_at: timestamp
}

entity work_day {
    *<u>timesheet_id</u>: <<uuid>>
    *<u>work_date</u>: date
    ---
    *worked_hours: int
    *worked_minutes: int
    commentary: text
    *is_editable: boolean
    *created_at: timestamp
    *edited_at: timestamp
    deleted_at: timestamp
}

together {
    entity event {
        *<u>event_id</u>: <<uuid>>
        avatar_id: <<uuid>> (FK file)
        ---
        *name: varchar(255)
        description: text
        website: url
        *created_at: timestamp
        *edited_at: timestamp
        deleted_at: timestamp
    }

    entity event_time_slot {
        *<u>event_time_slot_id</u>: <<uuid>>
        *event_id: <<uuid>>
        avatar_id: <<uuid>> (FK file)
        ----
        *time_from: timestamp
        *time_to: timestamp
        slot_name: varchar(255)
        description: text
        *created_at: timestamp
        *edited_at: timestamp
        deleted_at: timestamp
    }

    entity event_timespan_range {
        *<u>event_timespan_range_id</u>: <<uuid>>
        *event_id: <<uuid>>
        ---
        *time_from: timestamp
        *time_to: timestamp
    }
}

entity task {
    *<u>task_id</u>: <<uuid>>
    *creator_id: uuid (FK event_staff)
    --
    *title: text
    *description: text
    *accomplished_level: int
    date_accomplished: timestamp
    *priority: <<enum TaskPriority>>
    *created_at: timestamp
    *edited_at: timestamp
    deleted_at: timestamp
}

entity assigned_staff {
    *<u>task_id</u>: <<uuid>>
    *<u>staff_id</u>: <<uuid>>
}

entity company {
    *<u>company_id</u>: <<uuid>>
    avatar_id: <<uuid>> (FK file)
    ---
    *name: varchar(255)
    description: text
    website: url
    *created_at: timestamp
    *edited_at: timestamp
    deleted_at: timestamp
}

entity associated_company {
    *<u>event_id</u>: <<uuid>>
    *<u>company_id</u>: <<uuid>>
    ---
    *association_type: <<enum AssociationType>>
}

entity employment {
    *<u>user_id</u>: <<uuid>>
    *<u>company_id</u>: <<uuid>>
    ---
    *employment_type: <<enum EmploymentType>>
    *hourly_rate: float
    *employee_level: <<enum EmployeeLevel>>
    *created_at: timestamp
    *edited_at: timestamp
    deleted_at: timestamp
}

entity event_staff {
    *<u>user_id</u>: <<uuid>>
    *<u>event_id</u>: <<uuid>>
    ---
    *staff_level: <<enum StaffLevel>>
    *created_at: timestamp
    *edited_at: timestamp
    deleted_at: timestamp
}

together {
    entity comment {
        *<u>comment_id</u>: <<uuid>>
        event_id: <<uuid>>
        task_id: <<uuid>>
        *author_id: <<uuid>>
        ---
        *content: text
        *created_at: timestamp
        *edited_at: timestamp
        deleted_at: timestamp
    }

    /'
    A `file` table allows to refer to file system paths by joining
    `file_id` and `extension` (and possibly using attributes like `type`).

    The `FileType` enum determines how the file is treated (e.g. image, text).
    It is expected to be used to determine how to present the file.
    be utilized for constructing a file system path the file gets stored at
    (and store all images under a dedicated `image/` directory for instance).

    The `params` column may optionally contain values in `param=value;` format.
    In case of images, it may store params representing e.g. width and height.
    '/
    entity file {
        *<u>file_id</u>: <<uuid>>
        comment_id: <<uuid>>
        ---
        extention: varchar(20)
        params: varchar(60)
        *type <<enum FileType>>
        *created_at: timestamp
        deleted_at: timestamp
    }
}

user||..|{employment
timesheet}o..||employment
timesheet||..o{work_day
employment}o..||company
event||.o{associated_company
company||..o{associated_company
event||..o{event_staff
event||..o{task
event||...o{event_time_slot
event|o...o{comment
event||...o{event_timespan_range
task|o...o{comment
comment}o..||user
task||..||event_staff : task_creator
task||..o{assigned_staff
assigned_staff}o..||event_staff
user||..o{event_staff
file}o..o|comment
file|o..o|company
file|o..o|event
file|o..o|event_time_slot
file|o..o|user
@enduml