Skip to content

UML to Relations

Nantawan Paramapooti edited this page Nov 29, 2024 · 21 revisions

To be updated

UML class Relationships to Relation tables explanation

1. User posts content

Screenshot 2024-11-13 160018

This relation represents posts made by users in the system. Each user can create multiple posts, allowing for a one-to-many relationship between the User table and the Post table

2. Chatroom

Chatroom 2024-11-13 160124

This relation represents chat rooms that users can join. Each chat room is identified by a unique chat_id and has a chat_name for easy identification. Users can participate in multiple chat rooms, enabling group conversations or topic-specific discussions within the application.

3. User Block

User Block 2024-11-13 160153

This relation represents the blocking relationships between users, allowing for a many-to-many association where one user can block multiple users

4. User Follow

Userfollow 2024-11-13 160307

This relation represents the following relationships between users, allowing for a many-to-many association where one user can follow each other.

5. Message

Message 2024-11-13 160352

This relation represents messages sent by users in chat rooms. Each message is associated with one user (sender_id) and one chat room (chat_id). However, each chat room can contain multiple messages, reflecting the many-to-one relationship between Message and ChatRoom

6. Comment

Comment 2024-11-13 160715

This table represents comments made by users on posts. Each comment is linked to a specific user (sender_id) and a specific post (post_id). This setup allows each post to have multiple comments from different users, reflecting the one-to-many relationship between Post and Comment.

7. Tag

Tag 2024-11-13 160756

The table serves to organize and categorize posts within the application, allowing users to easily find and filter posts based on relevant keywords. Each tag can be associated with one or more posts, and each post can have multiple tags, facilitating a many-to-many relationship between posts and tags.

8. Likes

Likes 2024-11-13 160901

Each record represents a like given by a specific user (liker_id) on a specific post (post_id). This setup enables a many-to-many relationship between User and Post, as each user can like multiple posts, and each post can receive multiple likes.

9. Shares

Shares 2024-11-13 160930

Each user can share multiple posts, and each post can be shared by multiple users, creating a many-to-many relationship between User and Post through the Shares table.

Translated Relations Result

Relation Attribute Foreign keys
Post post_id
user_id
p_content
timestamp
user_id: User(user_id)
Follower user_id
follower_id
user_id: User(user_id)
follower_id: User(user_id)
Blocker blocker_id
blocked_id
blocker_id: User(user_id)
blocked_id: User(user_id)
User user_id
username
email
password
name
bio
UserChat user_id
chat_id
user_id: User(user_id)
chat_id: ChatRoom(chat_id)
ChatRoom chat_id
chat_name
Message message_id
user_id
chat_id
ms_content
timestamp
user_id: User(user_id)
chat_id: ChatRoom(chat_id)
Comment comment_id
user_id
post_id
c_content
timestamp
user_id: User(user_id)
post_id: Post(post_id)
Tag tag_id
tag_content
PostTag tag_id
post_id
tag_id: Tag(tag_id)
post_id: Post(post_id)
Likes like_id
user_id
post_id
user_id: User(user_id)
post_id: Post(post_id)
Shares share_id
user_id
post_id
share_type
post_id: Post(post_id)
user_id: User(user_id)

Clone this wiki locally