-
Notifications
You must be signed in to change notification settings - Fork 0
UML to Relations
Translating directly from UML we've got:
| Relation | Attribute |
|---|---|
| Post | post_id post_content timestamp filter_content |
| User | user_id |
| ChatRoom | chatroom_id |
| ChatRequest | chatrequest_id action status |
| ChatRole | chatrole_id |
| ChatRank | chatrank_id chatrank_name allowed_actions |
| Message | message_id message_content timestamp |
| Comment | comment_id comment_content timestamp |
| Tag | tag_id tag_content |
| Like | like_id like_type |
| Share | share_id share_type |
| Report | report_id report_content is_justified |
| ReportType | report type_id reporttype_name reporttype_content |
| Notification | notification_id is_read timestamp |
Image from UML can be merged into PostImage and will be explained in the following translation
Explaination: A Post can get many to no Likes, but a Like belongs to a Post
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Like | ... post_id |
post_id : Post(post_id) |
Explaination: A User posts a Post, but a Post can have only one User.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Post | ... user_id |
user_id : User(user_id) |
Explaination: A Post can have many to no Tags, while a Tag always atleast have 1 post
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| PostTag | tag_id post_id |
tag_id : Tag(tag_id) post_id : Post(post_id) |
Explaination: A Post may have many to no Comments, but a Comment belongs to one Post.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Comment | ... post_id |
post_id : Post(post_id) |
Explaination: A Post may have many to no Shares, but a Share belongs to one Post.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Share | ... post_id |
post_id : Post(post_id) |
Explaination: A Post may have many to no Images, but a Image belongs to one Post.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| PostImage | post_id | post_id : Post(post_id) |
Explaination: A Post creation sends a notification to Post owner's followers, whereas the relationship of Post to Notification is a one-to-one.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Notification | ... notification_of |
notification_of : Class object Post |
Explaination: A Post may never or have been reported many times, but a Report belongs to one Post.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Report | ... report_of |
report_of : Class object Post |
Explaination: A Like sends a notification to Post owner, whereas the relationship of Like to Notification is a one-to-one.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Notification | ... notification_of |
notification_of : Class object Like |
Explaination: A Like can only be created by a User, but a User can create many likes.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Like | ... user_id |
user_id : User(user_id) |
Explaination: A Share sends a notification to Post owner, whereas the relationship of Share to Notification is a one-to-one.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Notification | ... notification_of |
notification_of : Class object Share |
Explaination: A Share can only be created by a User, but a User can create many shares.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Share | ... user_id |
user_id : User(user_id) |
Explaination: A User may have many to no interests, which can be represented by Tags, and a Tag many have many to no Users who's interested.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| UserInterest | user_id tag_id |
user_id: User(user_id) tag_id : Tag(tag_id) |
Explaination: A User may have many to no disinterests, which can be represented by Tags, and a Tag many have many to no Users who's disinterested.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| UserDisinterest | user_id tag_id |
user_id: User(user_id) tag_id : Tag(tag_id) |
Explaination: Comment creation sends a notification to Post owner, whereas the relationship of Comment to Notification is a one-to-one.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Notification | ... notification_of |
notification_of : Class object Comment |
Explaination: A Comment may never or have been reported many times, but a Report belongs to one Comment.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Report | ... report_of |
report_of : Class object Comment |
Explaination: A Comment can only be created by a User, but a User can create many comments.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Comment | ... user_id |
user_id : User(user_id) |
Explaination: A User may never or have been reported many times, but a Report belongs to one User.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Report | ... report_of |
report_of : Class object User |
Explaination: A User can submit many Reports, but a Report can only belong to one User.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Report | ... reporter_id |
reporter_id : User(user_id) |
Explaination: A User will receive a notification per each Notification created for them.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Notification | ... receiver_id |
receiver_id : User(user_id) |
Explaination: A User can block many to no Users and a User themselves can be blocked by many Users.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Block | blocker_id blocked_id |
blocker_id: User(user_id) blocked_id: User(user_id) |
Explaination: A User can follow many to no Users and a User themselves can be followed by many Users.
Followers may choose whether they want to be notified whenever a Post is created by the User they followed as well.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Follow | user_id follower_id notify |
user_id: User(user_id) follower_id: User(user_id) |
Explaination: A User receives a notification when they are followed by other users, whereas the relationship of Follow action to Notification is a one-to-one.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Notification | ... notification_of |
notification_of : Class object Follow |
ReportType Justification: In contrast to other types attributes, Reports can have overlapping issues across themselves, thus it would be useful to create ReportType for Report to categorize problems so we can set up a solution protocol/pipeline for each problem to automate the solving process, as more Users use the platform, more problems arise, thus it necessary to make ReportType more flexible and adaptive to changes.
Explaination: A Report can only have one ReportType, while a ReportType may have many to no Reports.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Report | ... reporttype_id |
reporttype_id : ReportType(reporttype_id) |
Explaination: Users may be in many to no ChatRooms, but a ChatRoom requires at least one user.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| ChatRole | ... user_id chatroom_id |
user_id : User(user_id) chatroom_id :ChatRoom(chatroom_id) |
Explaination: Each User have a Ranking within a ChatRoom (admin, moderator, vip, member, etc.)
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| ChatRole | ... chatrank_id |
chatrank_id : ChatRank(chatrank_id) |
Explaination: A ChatRoom may never or have been reported many times, but a Report belongs to one ChatRoom.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Report | ... report_of |
report_of : Class object ChatRoom |
Explaination: ChatRole changes sends a notification to User of the ChatRole, whereas the relationship of ChatRole to Notification is a many-to-one.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Notification | ... notification_of |
notification_of : Class object ChatRole |

Explaination: A ChatRoom may have many to no ChatRequest, but a ChatRequest can only belong to one ChatRoom
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| ChatRequest | chat_id | chat_id : ChatRoom(chat_id) |
Explaination: Both Sender and Receiver of ChatRequest may receive a Notification, depending on the context of ChatRequest, but atleast one Notification of ChatRequest is created. While those Notifications is created belonging to one ChatRequest.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Notification | ... notification_of |
notification_of : Class object ChatRequest(receiver/sender is handled differently) |
Explaination: A User who is not yet in the ChatRoom may receive many to no ChatRequest, but a ChatRequest can only be sent to a User.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| ChatRequest | ... receiver |
receiver : User(user_id) |
Explaination: A User who is in the ChatRoom may send many to no ChatRequest, but a ChatRequest can only be sent by a User.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| ChatRequest | ... sender |
sender : User(user_id) |
Explaination: A Message may never or have been reported many times, but a Report belongs to one Message.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Relation | Attribute | Foreign keys |
| - | - | - |
| Report | ... report_of |
report_of : Class object Message |
Explaination: A User may send many to no Messages, but a Message can only be sent by a User.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Message | ... user_id |
user_id : User(user_id) |
Explaination: Message creation sends a notification to every other user in the ChatRoom, whereas the relationship of Message to Notification is a one-to-one.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Notification | ... notification_of |
notification_of : Class object Message |

Explaination: A ChatRoom may have many to no Messages, but a Message can only belong to one ChatRoom.
Updated changes:
| Relation | Attribute | Foreign keys |
|---|---|---|
| Message | chat_id | chat_id : ChatRoom(chat_id) |
| Relation | Attribute | Foreign keys |
|---|---|---|
| Post | post_id user_id post_content timestamp filter_content |
user_id: User(user_id) |
| Follow | user_id follower_id notify |
user_id: User(user_id) follower_id: User(user_id) |
| Block | blocker_id blocked_id |
blocker_id: User(user_id) blocked_id: User(user_id) |
| User | user_id username password user_name birthday bio profile header color language filter_content |
|
| UserChat | user_id chat_id |
user_id: User(user_id) chat_id: ChatRoom(chat_id) |
| UserInterest | user_id tag_id |
user_id: User(user_id) tag_id : Tag(tag_id) |
| UserDisinterest | user_id tag_id |
user_id: User(user_id) tag_id : Tag(tag_id) |
| ChatRoom | chat_id chat_name profile |
|
| ChatRequest | chatrequest_id chat_id sender receiver action status |
chat_id : ChatRoom(chat_id) sender : User(user_id) receiver : User(user_id) |
| ChatRole | chatrole_id user_id chatroom_id chatrank_id |
user_id : User(user_id) chatroom_id : ChatRoom(chatroom_id) chatrank_id : ChatRank(chatrank_id) |
| ChatRank | chatrank_id chatrank_name allowed_actions |
|
| Message | message_id user_id chat_id message_content timestamp |
user_id: User(user_id) chat_id: ChatRoom(chat_id) |
| Comment | comment_id user_id post_id comment_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) |
| Like | like_id user_id post_id like_type |
user_id: User(user_id) post_id: Post(post_id) |
| Share | share_id user_id post_id share_type |
post_id: Post(post_id) user_id: User(user_id) |
| ReportType | reporttype_id reporttype_name reporttype_content |
|
| Report | report_id report_of reporter_id reporttype_id report_content is_justified |
report_of : Class object User, Post, Comment, Chatroom, Message reporter_id : User(user_id) reporttype_id : ReportType(reporttype_id) |
| PostImage | postimage_id post_id image |
post_id : Post(post_id) |
| Notification | notification_id notification_of receiver_id is_read timestamp |
notification_of : Class object Follow, Like, Share, Post, Comment, Message, ChatRole, ChatRequest(receiver/sender is different) receiver_id : User(user_id) |