database schema for timesheet

前端 未结 5 1976
青春惊慌失措
青春惊慌失措 2021-02-02 03:17

Could someone help me with a rough database schema for a timesheet application where the i would be able to

  1. Store hours per day for a time period ( 2 weeks ) fo

5条回答
  •  故里飘歌
    2021-02-02 03:44

    The following code is taken from the ]project-open[ open-source system in PostgreSQL syntax and edited.

    Please note the "conf_objects" table with approval/confirmation information. When the user "submits" a time sheet, all submitted hours are assigned to a new conf_object. It's the job of the supervisor to set the status of the conf_object to "approved". Both the supervisor or the user may delete the conf_object at any time, which will will mark the hours as "not submitted" (hour.conf_object_id = NULL) again, so that these hours will end up on the "Hours Not Submitted" report.

    CREATE TABLE projects (
        project_id                      integer constraint projects_pk primary key,
        project_name                    text not null,
        parent_id                       integer constraint projects_parent_fk references projects,
    [...]
        project_type_id                 integer not null constraint projects_prj_type_fk references categories,
        project_status_id               integer not null constraint projects_prj_status_fk references categories,
        description                     text,
        start_date                      timestamptz,
        end_date                        timestamptz
    );
    
    
    CREATE TABLE users (
        user_id integer constraint users_pk primary key,
        first_names text,
        last_name text
    [...]
    );
    
    -- Confirmation (=approval) objects
    CREATE TABLE conf_objects (
        conf_id         integer constraint conf_id_pk primary key,
        conf_status_id  integer constraint conf_status_nn not null
    );
    
    
    CREATE TABLE hours (
        user_id                 integer constraint hours_user_id_nn not null constraint hours_user_id_fk references users,
        project_id              integer constraint hours_project_id_nn not null constraint hours_project_id_fk references projects,
        day                     date constraint hours_day_nn not null,
        hours                   numeric(5,2) not null,
    [...]
        note                    text,
        conf_object_id          integer constraint hours_conf_object_fk references conf_objects
    );
    

    The original ]po[ SQL statements are included in the ~/packages/intranet-*/sql/postgresql/intranet-*-create.sql creation scripts.

提交回复
热议问题