wiki:AdminManagesGenres

Version 1 (modified by 211099, 2 weeks ago) ( diff )

--

Admin Manages Genres

Actor: Admin

An admin adds a new genre to the platform or removes an existing one that is no longer needed.

1. The admin navigates to the "Manage Genres" section in the admin dashboard.

2. The system displays all existing genres and their usage counts.

SELECT g.genre_id, g.name, COUNT(hg.story_id) AS stories_using_genre
FROM GENRE g
LEFT JOIN HAS_GENRE hg ON g.genre_id = hg.genre_id
GROUP BY g.genre_id
ORDER BY g.name ASC;

3. The admin selects "Add New Genre" and enters the genre name.

4. The system checks if the genre already exists.

SELECT * FROM GENRE
WHERE LOWER(name) = LOWER('Science Fiction');

5. The genre does not exist, so the system inserts it.

INSERT INTO GENRE (name)
VALUES ('Science Fiction');

6. The admin also decides to delete an unused genre.

7. The system checks if any stories are currently using that genre before deleting.

SELECT COUNT(*) AS usage_count
FROM HAS_GENRE
WHERE genre_id = 10;

8. Since no stories use it, the system deletes the genre.

DELETE FROM GENRE
WHERE genre_id = 10;

9. The system confirms both changes and refreshes the genre list.

Note: See TracWiki for help on using the wiki.