= Use-case UC0001 – Admin creates and assigns a task to workers = '''Initiating actor:''' Admin '''Other actors:''' Worker (assigned to the task) '''Description:''' The Admin creates a new task under an existing project and assigns one or more workers to carry it out. So the Admin never has to remember identifiers, the system first lists the available projects and workers to choose from; the task and its worker assignments are then written to the database. == Scenario == 1. '''Admin''' chooses "Create Task" and the system shows a form. To populate the project selector, the '''system''' lists the available projects: {{{ #!sql SELECT p.id, p.name, p.status, u.name AS client FROM project.projects p LEFT JOIN project.users u ON u.id = p.client_id ORDER BY p.id; }}} 2. To populate the worker selector, the '''system''' lists the available workers with their skills: {{{ #!sql SELECT id, name, email, skills FROM project.users WHERE role = 'WORKER' ORDER BY name; }}} 3. '''Admin''' fills in the task title, description, due date, picks the project from the list, and selects the workers to assign. 4. '''System''' validates the input and inserts the new task: {{{ #!sql INSERT INTO project.tasks (title, description, status, due_date, client_id, project_id) VALUES ('Prepare launch checklist', 'Pre-launch QA checklist', 'PENDING', TIMESTAMP '2026-08-15', 4, 1) RETURNING id, title, status, client_id, project_id; }}} 5. '''System''' inserts the worker assignments into the associative table (one row per selected worker): {{{ #!sql INSERT INTO project.task_workers (task_id, user_id) VALUES (11, 2), (11, 7) RETURNING id, task_id, user_id; }}} 6. '''System''' confirms the task was created and shows it in the task list with its assigned workers. The task INSERT and the worker-assignment INSERTs are executed together in one transaction, so a task is never created without its assignments (or vice versa).