== ERModel Current version == == Diagram == [[Image(KristinaSrbinoskaER.4.jpg)]] == Data requirements == === ENTITIES === {{{USER}}} [[BR]] Represents each individual user at the platform. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * {{{user_id}}} – numeric identifier (primary key). [[BR]] '''[[span(style=color: #9A0000, Attributes:)]]''' * {{{user_id}}} – numeric, required. Primary key. * {{{username}}} – text, required, unique. * {{{email}}} – text, required, unique. * {{{name}}} – text, required. * {{{surname}}} – text, required. * {{{password}}} – hash value, required. [[BR]] ---- {{{ADMIN}}} [[BR]] Represents the admin user (full access of the system). Inherited from USER. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * {{{user_id}}} – inherited primary key. [[BR]] '''[[span(style=color: #9A0000, Inheritance:)]]''' Inherits all attributes from USER. [[BR]] ---- {{{REGULAR_USER}}} [[BR]] Represents regular users. Inherited from USER. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * {{{user_id}}} – inherited primary key. [[BR]] '''[[span(style=color: #9A0000, Inheritance:)]]''' Inherits all attributes from USER [[BR]] ---- {{{WRITER}}} [[BR]] Represents writers. Inherited from USER. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * {{{user_id}}} – inherited primary key. [[BR]] '''[[span(style=color: #9A0000, Inheritance:)]]''' Inherits all attributes from USER [[BR]] ---- {{{STORY}}} [[BR]] Represents every story that is written in the platform. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * {{{story_id}}} – surrogate numeric identifier (primary key). [[BR]] '''[[span(style=color: #9A0000, Attributes:)]]''' * {{{story_id}}} – numeric, required. Auto-generated primary key. * {{{mature_content}}} – boolean, required. Indicates if story contains mature content. * {{{short_description}}} – text, required. Brief description of the story. * {{{content}}} – text, required. Full content of the story. * {{{status}}} – multi-valued text, required. Publication status (draft, published, archived). A story can have multiple status values over time. * {{{image}}} – text, optional. URL or path to story cover image. [[BR]] ---- {{{CHAPTER}}} [[BR]] Represents a chapter, which is part of a story. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * {{{chapter_id}}} – surrogate numeric identifier (primary key). [[BR]] '''[[span(style=color: #9A0000, Attributes:)]]''' * {{{chapter_id}}} – numeric, required. Auto-generated primary key. * {{{chapter_number}}} – numeric, required. Order number of the chapter within the story. * {{{chapter_name}}} – text, required. Name of the chapter. * {{{title}}} – text, required. Title of the chapter. * {{{content}}} – text, required. Content of the chapter. * {{{word_count}}} – numeric, optional. Number of words in the chapter. * {{{rating}}} – numeric, optional. Rating of the chapter. * {{{published_at}}} – timestamp, required. Publication date and time. * {{{view_count}}} – numeric, optional. Number of views. [[BR]] ---- {{{GENRE}}} [[BR]] Represents a genre category for stories. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * {{{genre_id}}} – surrogate numeric identifier (primary key). [[BR]] '''[[span(style=color: #9A0000, Attributes:)]]''' * {{{genre_id}}} – numeric, required. Auto-generated primary key. * {{{name}}} – text, required, unique. Name of the genre. [[BR]] ---- {{{READING_LIST}}} [[BR]] Represents a reading list created by users. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * {{{list_id}}} – surrogate numeric identifier (primary key). [[BR]] '''[[span(style=color: #9A0000, Attributes:)]]''' * {{{list_id}}} – numeric, required. Auto-generated primary key. * {{{name}}} – text, required. Name of the reading list. * {{{content}}} – text, optional. Description of the reading list. * {{{is_public}}} – boolean, required. Visibility of the reading list. [[BR]] ---- {{{NOTIFICATION}}} [[BR]] Represents notifications sent to users. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * {{{notification_id}}} – surrogate numeric identifier (primary key). [[BR]] '''[[span(style=color: #9A0000, Attributes:)]]''' * {{{notification_id}}} – numeric, required. Auto-generated primary key. * {{{content}}} – text, required. Content of the notification. * {{{content_type}}} – multi-valued text, required. Type of notification content. A notification can belong to multiple content types. * {{{is_read}}} – boolean, required. Indicates whether the notification has been read. Default: false. [[BR]] ---- {{{AI_SUGGESTION}}} [[BR]] Represents AI-generated suggestions for story improvements. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * {{{suggestion_id}}} – surrogate numeric identifier (primary key). [[BR]] '''[[span(style=color: #9A0000, Attributes:)]]''' * {{{suggestion_id}}} – numeric, required. Auto-generated primary key. * {{{original_text}}} – text, required. Original text from the story. * {{{suggested_text}}} – text, required. AI-suggested improvement. * {{{suggestion_type}}} – multi-valued text, required. Type of suggestion (grammar, style, etc.). A suggestion can belong to multiple types. * {{{accepted}}} – boolean, required. Whether the suggestion was accepted. [[BR]] ---- {{{LIKE}}} [[BR]] Represents likes given by users to stories. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * Composite key: ({{{user_id}}}, {{{story_id}}}). [[BR]] ---- {{{COMMENT}}} [[BR]] Represents comments made by users on stories. [[BR]] '''[[span(style=color: #9A0000, Candidate keys:)]]''' * {{{comment_id}}} – surrogate numeric identifier (primary key). [[BR]] '''[[span(style=color: #9A0000, Attributes:)]]''' * {{{comment_id}}} – numeric, required. Auto-generated primary key. * {{{content}}} – text, required. Content of the comment. [[BR]] ---- === RELATIONS === {{{has_list (USER – READING_LIST)}}} [[BR]] Represents users having reading lists. [[BR]] '''[[span(style=color: #9A0000, Cardinality:)]]''' 1:N (One user can have many reading lists, each reading list belongs to one user) [[BR]] '''[[span(style=color: #9A0000, Keys:)]]''' Foreign key: {{{user_id}}} in READING_LIST references USER. [[BR]] ---- {{{reading_list_items (READING_LIST – STORY)}}} [[BR]] Represents stories added to reading lists. [[BR]] '''[[span(style=color: #9A0000, Cardinality:)]]''' Cardinality: M:N (Many reading lists can contain many stories)) [[BR]] '''[[span(style=color: #9A0000, Keys:)]]''' Keys: Composite key: (list_id, story_id). [[BR]] '''[[span(style=color: #9A0000, Attributes:)]]''' * {{{added_at}}} – timestamp, required. Date and time when the story was added to the reading list. [[BR]] ---- {{{collaboration (USER – STORY)}}} [[BR]] Represents users collaborating on stories. [[BR]] '''[[span(style=color: #9A0000, Cardinality:)]]''' M:N (Many users can collaborate on many stories) [[BR]] '''[[span(style=color: #9A0000, Keys:)]]''' Composite key: ({{{user_id}}}, {{{story_id}}}). [[BR]] '''[[span(style=color: #9A0000, Attributes:)]]''' * {{{role}}} – multi-valued text, required. Role of the collaborator. * {{{permission_level}}} – multi-valued numeric, optional. Level of permission for collaboration. [[BR]] ---- {{{created_story (WRITER – STORY)}}} [[BR]] Represents writers creating stories. [[BR]] '''[[span(style=color: #9A0000, Cardinality:)]]''' 1:N (One writer can create many stories, each story is created by one writer) [[BR]] '''[[span(style=color: #9A0000, Keys:)]]''' Foreign key: {{{user_id}}} in STORY references WRITER. [[BR]] ---- {{{has_genre (STORY – GENRE)}}} [[BR]] Represents stories having genres. [[BR]] '''[[span(style=color: #9A0000, Cardinality:)]]''' M:N (Many stories can have many genres) [[BR]] '''[[span(style=color: #9A0000, Keys:)]]''' Composite key: ({{{story_id}}}, {{{genre_id}}}). [[BR]] ---- {{{part_of (CHAPTER – STORY)}}} [[BR]] Represents chapters being part of stories. [[BR]] '''[[span(style=color: #9A0000, Cardinality:)]]''' N:1 (Many chapters are part of one story) [[BR]] '''[[span(style=color: #9A0000, Keys:)]]''' Foreign key: {{{story_id}}} in CHAPTER references STORY. [[BR]] ---- {{{is_liked (USER – LIKE – STORY)}}} [[BR]] Represents likes given by users to stories. [[BR]] '''[[span(style=color: #9A0000, Cardinality:)]]''' User 1:N LIKE, Story 1:N LIKE (One user can like many stories, one story can have many likes) [[BR]] '''[[span(style=color: #9A0000, Keys:)]]''' Composite key: (user_id, story_id) in LIKE Foreign key: {{{user_id}}} in LIKE references USER. Foreign key: {{{story_id in}}} LIKE references STORY. [[BR]] ---- {{{is_commented (USER – COMMENT – STORY)}}} [[BR]] Represents comments made by users on stories. [[BR]] '''[[span(style=color: #9A0000, Cardinality:)]]''' User 1:N COMMENT, Story 1:N COMMENT (One user can make many comments, one story can have many comments) [[BR]] '''[[span(style=color: #9A0000, Keys:)]]''' Foreign key: {{{user_id}}} in COMMENT references USER. Foreign key: {{{story_id in}}} COMMENT references STORY. [[BR]] ---- {{{notify (USER – STORY – NOTIFICATION)}}} [[BR]] Represents notifications sent to users about stories. [[BR]] '''[[span(style=color: #9A0000, Cardinality:)]]''' M:N:P (Many users can receive many notifications about many stories) [[BR]] '''[[span(style=color: #9A0000, Keys:)]]''' Composite key: ({{{user_id}}},{{{story_id}}},{{{notification_id}}}) Foreign key: {{{user_id}}} references USER Foreign key: {{{story_id}}} references STORY. Foreign key: {{{notification_id}}} references NOTIFICATION. [[BR]] ---- {{{need_approval (AI_SUGGESTION – STORY – CHAPTER)}}} [[BR]] Represents AI suggestions needing approval for specific chapters within stories. [[BR]] '''[[span(style=color: #9A0000, Cardinality:)]]''' M:N:P (Many AI suggestions can be made for many stories across many chapters) [[BR]] '''[[span(style=color: #9A0000, Keys:)]]''' Composite key: ({{{suggestion_id}}},{{{story_id}}},{{{chapter_id}}}) Foreign key: {{{suggestion_id}}} references AI_SUGGESTION. Foreign key: {{{story_id}}} references STORY. Foreign key: {{{chapter_id}}} references CHAPTER. [[BR]] ---- {{{suggested (STORY – AI_SUGGESTION)}}} [[BR]] Represents stories having AI-generated suggestions. [[BR]] '''[[span(style=color: #9A0000, Cardinality:)]]''' 1:N (One story can have many AI suggestions) [[BR]] '''[[span(style=color: #9A0000, Keys:)]]''' Foreign key: {{{story_id}}} in AI_SUGGESTION references STORY.