Timesheet tracking for employees and managers
TimesheetUser
|-- userId (Google's unique identifier, often 'sub' from the OAuth response)
|-- username (optional, might not be provided by Google)
|-- email (user's email address from Google OAuth)
|-- managerId (FK)
|-- isManager
Timesheet
|-- timesheetId
|-- userId (FK)
|-- endDate
|-- status
TimesheetEntry
|-- entryId
|-- timesheetId (FK)
|-- projectId (FK)
|-- hoursWorked
|-- date
Project
|-- projectId
|-- projectName
Aliases
|-- userId (FK)
|-- projectId (FK)
|-- alias
-
Properties:
- userId (use the unique identifier from Google OAuth, often called sub)
- username (optional, as it may not be provided by Google)
- email (the user's email address from Google OAuth)
- managerId
- isManager (boolean)
-
Relationships:
- One user can have multiple timesheets.
- One manager can have multiple employees.
-
Properties:
- timesheetId
- userId (foreign key)
- endDate
- status
-
Relationships:
- One timesheet belongs to one user.
- One timesheet has multiple entries (representing hours worked on different projects on different days).
-
Properties:
- entryId
- timesheetId (foreign key)
- projectId
- hoursWorked
- date
-
Relationships:
- One entry belongs to one timesheet.
- One entry is associated with one project and one date.
-
Properties:
- projectId
- projectName
-
Relationships:
- One project can be associated with multiple entries in different timesheets.
- Properties
- userId (foreign key)
- projectId (foreign key)
- alias (string)
- Relationships
- one alias is associated with one project for one user
- Setting up projects table
CREATE TABLE Project (
projectId SERIAL PRIMARY KEY,
projectName VARCHAR(255) NOT NULL
);- Setting up timesheetEntries table
CREATE TABLE TimesheetEntry (
entryId SERIAL PRIMARY KEY,
timesheetId INT,
projectId INT,
hoursWorked INT,
date DATE,
FOREIGN KEY (timesheetId) REFERENCES Timesheet(timesheetId),
FOREIGN KEY (projectId) REFERENCES Project(projectId)
);- Setting up the timesheets table
CREATE TABLE Timesheet (
timesheetId SERIAL PRIMARY KEY,
userId VARCHAR(255),
endDate DATE,
status VARCHAR(10) CHECK (status IN ('approved', 'working', 'submitted', 'revise')),
FOREIGN KEY (userId) REFERENCES TimesheetUser(userId)
);- Setting up the users table
CREATE TABLE TimesheetUser (
userId VARCHAR(255) PRIMARY KEY,
email VARCHAR(255) NOT NULL,
managerId VARCHAR(255),
isManager BOOLEAN,
FOREIGN KEY (managerId) REFERENCES TimesheetUser(userId)
);