== Writer Adds a Chapter to a Story === Authors: **Writter** A writer adds a new chapter to an existing published or draft story, providing chapter details such as title, content, and chapter number. **1.** The writer navigates to their story and selects "Add New Chapter". **2.** The system displays the chapter creation form requesting chapter number, chapter name, title, and content. **3.** The system checks what chapter number should come next. {{{#!sql SELECT MAX(chapter_number) + 1 AS next_chapter FROM CHAPTER WHERE story_id = 1; }}} **4.** The writer fills in all chapter details and submits the form. **5.** The system inserts a new record into the CHAPTER table. {{{#!sql INSERT INTO CHAPTER (chapter_number, chapter_name, title, content, word_count, published_at, view_count, story_id, created_at, updated_at) VALUES (4, 'Chapter Four', 'The Council of Kings', 'Lyra stood before the five thrones, her heart hammering...', 3800, CURRENT_TIMESTAMP, 0, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); }}} **6.** The system notifies all users who have the story in their reading list. {{{#!sql INSERT INTO NOTIFICATION (content, is_read, created_at) VALUES ('Elena published a new chapter of "The Chronicles of Eldoria"', FALSE, CURRENT_TIMESTAMP); }}} **7.** The system confirms the chapter was added and displays it on the story page.