Welcome to the database schema documentation for the Team Manager application! This guide provides a detailed overview of the underlying data structure that powers our project and task management system.
The database schema is intelligently managed by Spring Data JPA and Hibernate, meaning it's automatically generated and updated based on our Java entity definitions located in the com.task.TeamManager.model package.
Our database is structured around five core entities, designed to manage users, their roles, various projects, and the tasks within them:
- 👥
users: Where all user authentication and profile information resides. - 🔑
roles: Defines the different access levels and responsibilities within the application. - 🤝
user_roles: The crucial link that connects users to their assigned roles. - 🏗️
projects: Details about all the exciting projects being managed. - ✅
tasks: The actionable items, linked to projects and assigned to team members.
Let's dive into the specifics of each table:
- Purpose: Manages user accounts, profiles, and login credentials.
- Columns:
id(BIGINT): Primary Key, auto-generated unique identifier.username(VARCHAR(255)): User's unique login name.NOT NULL,UNIQUE.email(VARCHAR(255)): User's email address.NOT NULL,UNIQUE.password(VARCHAR(255)): Hashed password for security.NOT NULL.created_at(DATETIME/TIMESTAMP): Timestamp of account creation.NOT NULL, auto-generated on insert.
- Purpose: Defines system-wide roles that can be assigned to users.
- Columns:
id(BIGINT): Primary Key, auto-generated unique identifier.name(VARCHAR(255)): Unique name of the role (e.g.,'ROLE_ADMIN','ROLE_USER').NOT NULL,UNIQUE.
- Purpose: A dedicated join table to handle the Many-to-Many relationship between
usersandroles. This allows a user to have multiple roles, and a role to be assigned to multiple users. - Columns:
user_id(BIGINT): Part of composite Primary Key.NOT NULL.role_id(BIGINT): Part of composite Primary Key.NOT NULL.
- Primary Key: (
user_id,role_id) - ensures unique user-role combinations. - Foreign Keys:
user_id➡️ referencesusers.idrole_id➡️ referencesroles.id
- Purpose: Stores details and metadata for each project.
- Columns:
id(BIGINT): Primary Key, auto-generated unique identifier.name(VARCHAR(255)): Name of the project.NOT NULL.description(TEXT): Detailed project description. (Optional).start_date(DATE): The project's official start date.NOT NULL.end_date(DATE): The project's planned completion date. (Optional, allows for ongoing projects).project_manager_id(BIGINT): Foreign Key, links to theUsermanaging this project.NOT NULL.
- Foreign Keys:
project_manager_id➡️ referencesusers.id
- Purpose: Manages individual tasks, linking them to projects and assigning them to team members.
- Columns:
id(BIGINT): Primary Key, auto-generated unique identifier.title(TEXT): Short, descriptive title of the task.NOT NULL.description(TEXT): Detailed description of the task. (Optional).status(VARCHAR(255)): Current state of the task (e.g.,'TO_DO','IN_PROGRESS','DONE').NOT NULL.priority(VARCHAR(255)): Importance level of the task (e.g.,'LOW','MEDIUM','HIGH','CRITICAL').NOT NULL.due_date(DATE): The target completion date for the task. (Optional).project_id(BIGINT): Foreign Key, links to the parent project.NOT NULL.assigned_to_id(BIGINT): Foreign Key, links to theUserassigned to the task. (Optional, allows unassigned tasks).created_at(DATETIME/TIMESTAMP): Timestamp when the task was created.NOT NULL, auto-generated on insert.
- Foreign Keys:
project_id➡️ referencesprojects.idassigned_to_id➡️ referencesusers.id
Our schema establishes the following crucial connections:
- 👥 User 🤝 Role:
- Type: Many-to-Many
- How: Explicitly managed by the
user_rolesjoin table.Userhas manyUser_Roles.Rolehas manyUser_Roles.- Each
User_Rolesentry connects oneUserto oneRole.
- 👥 User ➡️ 🏗️ Project (Manager):
- Type: One-to-Many (One
Usercan manage multipleProjects). - How:
projects.project_manager_idcolumn points tousers.id.
- Type: One-to-Many (One
- 👥 User ➡️ ✅ Task (Assigned To):
- Type: One-to-Many (One
Usercan be assigned multipleTasks). - How:
tasks.assigned_to_idcolumn points tousers.id.
- Type: One-to-Many (One
- 🏗️ Project ➡️ ✅ Task:
- Type: One-to-Many (One
Projectcan have multipleTasks). - How:
tasks.project_idcolumn points toprojects.id.
- Type: One-to-Many (One
We utilize Java enums (ETaskStatus and ETaskPriority) for type safety and readability in our application code. In the database, these enums are persisted as VARCHAR (String) values. This means you'll see the exact enum names (e.g., "TO_DO", "HIGH") stored in the status and priority columns of the tasks table.
This schema is designed to be effortlessly managed by Spring Data JPA and Hibernate.
- Automatic Schema Generation: For convenience during development, ensure your
application.properties(orapplication.yml) includes aspring.jpa.hibernate.ddl-autosetting (e.g.,update,create,create-drop). Hibernate will then automatically create or update your database schema based on the entity definitions. - Local Development: If you're running with an embedded H2 database, you can usually access its web console at
http://localhost:8080/h2-console(adjust port if necessary) once the application is running, providedspring.h2.console.enabled=trueis set. - External Databases: For production-grade databases like PostgreSQL or MySQL, configure your connection details in
application.propertiesand use your preferred database management tool to connect and inspect the schema.