| | 1 | == Regular User Comments on a Story |
| | 2 | |
| | 3 | === Authors: ** Regular User** |
| | 4 | A regular user leaves a comment on a published story, and the writer receives a notification. |
| | 5 | |
| | 6 | **1.** The regular user opens a published story and scrolls to the comments section. |
| | 7 | |
| | 8 | **2.** The system displays all existing comments for the story. |
| | 9 | {{{#!sql |
| | 10 | SELECT c.comment_id, u.username, c.content, c.created_at |
| | 11 | FROM COMMENT c |
| | 12 | JOIN USERS u ON c.user_id = u.user_id |
| | 13 | WHERE c.story_id = 1 |
| | 14 | ORDER BY c.created_at DESC; |
| | 15 | }}} |
| | 16 | |
| | 17 | **3.** The user types a comment and submits it. |
| | 18 | |
| | 19 | **4.** The system inserts the new comment into the COMMENT table. |
| | 20 | {{{#!sql |
| | 21 | INSERT INTO COMMENT (content, user_id, story_id, created_at, updated_at) |
| | 22 | VALUES ('This is absolutely breathtaking! The world-building is incredible!', 4, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); |
| | 23 | }}} |
| | 24 | |
| | 25 | **5.** The system creates a notification for the writer. |
| | 26 | {{{#!sql |
| | 27 | INSERT INTO NOTIFICATION (content, is_read, created_at) |
| | 28 | VALUES ('Sara commented on your story "The Chronicles of Eldoria"', FALSE, CURRENT_TIMESTAMP); |
| | 29 | }}} |
| | 30 | |
| | 31 | **6.** The system records the notification type. |
| | 32 | {{{#!sql |
| | 33 | INSERT INTO CONTENT_TYPE (notification_id, content_type) |
| | 34 | VALUES (2, 'comment'); |
| | 35 | }}} |
| | 36 | |
| | 37 | **7.** The system links the notification to the writer. |
| | 38 | {{{#!sql |
| | 39 | INSERT INTO NOTIFY (user_id, story_id, notification_id) |
| | 40 | VALUES (2, 1, 2); |
| | 41 | }}} |
| | 42 | |
| | 43 | **8.** The system displays the new comment immediately under the story. |