== Writer Invites a Collaborator to a Story === Actor: **Writter** A writer invites another writer to collaborate on their story, assigning them a role and permission level within the collaboration. **1.** The writer navigates to their story management page and selects "Manage Collaborators". **2.** The system displays the current list of collaborators on the story. {{{#!sql SELECT u.username, u.name, u.surname, r.roles, p.permission_level FROM COLLABORATION c JOIN USERS u ON c.user_id = u.user_id JOIN ROLES r ON c.user_id = r.user_id AND c.story_id = r.story_id JOIN PERMISSION_LEVEL p ON c.user_id = p.user_id AND c.story_id = p.story_id WHERE c.story_id = 5; }}} **3.** The writer searches for another writer by username and selects them. **4.** The writer assigns a role and permission level to the new collaborator. **5.** TThe system inserts the new collaborator into the COLLABORATION table. {{{#!sql INSERT INTO COLLABORATION (user_id, story_id, created_at) VALUES (9, 5, CURRENT_TIMESTAMP); }}} **6.** The system assigns the role to the collaborator. {{{#!sql INSERT INTO ROLES (user_id, story_id, roles) VALUES (9, 5, 'co-author'); }}} **7.** The system assigns the permission level to the collaborator. {{{#!sql INSERT INTO PERMISSION_LEVEL (user_id, story_id, permission_level) VALUES (9, 5, 4); }}} **8.**The system sends a notification to the invited writer informing them of the collaboration. {{{#!sql INSERT INTO NOTIFICATION (content, is_read, created_at) VALUES ('You have been invited to collaborate on "Letters from Constantinople"', FALSE, CURRENT_TIMESTAMP); }}} **9.** The system confirms the collaborator was successfully added.