Sobes.tech
Middle

Design a physical data model for a task management system. Highlight all physical tables with primary (PK) and foreign (FK) keys. The model should cover all Use Cases you identified earlier.

sobes.tech AI

Answer from AI

For the task management system, the following main tables can be identified:

  1. Users — system users
  • PK: user_id
  • Fields: username, email, password_hash, created_at
  1. Tasks — tasks
  • PK: task_id
  • FK: assigned_to (user_id from Users) — user to whom the task is assigned
  • FK: created_by (user_id from Users) — user who created the task
  • Fields: title, description, status, priority, due_date, created_at, updated_at
  1. Projects — projects that group tasks
  • PK: project_id
  • FK: owner_id (user_id from Users) — project owner
  • Fields: name, description, created_at
  1. Task_Comments — comments on tasks
  • PK: comment_id
  • FK: task_id (from Tasks)
  • FK: author_id (user_id from Users)
  • Fields: content, created_at
  1. Task_History — history of task changes
  • PK: history_id
  • FK: task_id (from Tasks)
  • FK: changed_by (user_id from Users)
  • Fields: change_type, old_value, new_value, changed_at
  1. Project_Members — project participants
  • PK: (project_id, user_id)
  • FK: project_id (from Projects)
  • FK: user_id (from Users)
  • Fields: role

This model covers the main use cases:

  • Creating and assigning tasks
  • Managing projects and participants
  • Commenting on tasks
  • Tracking change history

Example of defining the Tasks table:

CREATE TABLE Tasks (
    task_id SERIAL PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    description TEXT,
    status VARCHAR(50) NOT NULL,
    priority INT,
    due_date DATE,
    assigned_to INT REFERENCES Users(user_id),
    created_by INT REFERENCES Users(user_id),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP
);
Design a physical data model for a task management… - sobes.tech