Skip to main content

User Table

Description: Stores user information.
Column NameTypeConstraintsDescription
idserialPrimary KeyUnique identifier for the user.
nametextNot NullName of the user (encrypted).
usernametextNot Null, UniqueUsername of the user.
emailtextNot Null, UniqueUser’s email address (encrypted).
phonetextUniqueUser’s phone number (encrypted).
imagetextNot NullURL of the user’s profile image (encrypted).
biotextUser’s biography.
roleenum user_roleNot Null, Default: userRole of the user (admin or user).
phoneVerifiedAttimestampTimestamp when the phone was verified.
verifiedAttimestampTimestamp when the user was verified.
createdAttimestampNot Null, Default NowTimestamp when the user was created.
codetextVerification code.
codeExpiredAttimestampTimestamp when the verification code expires.
tagstext[]Not Null, Default: empty arrayArray of tags associated with the user.
isSuspendedbooleanNot Null, Default: falseIndicates if the user is suspended.

Relationships

  • Sessions: A user can have multiple sessions.
  • Posts: A user can create multiple posts.
  • Following: A user can follow other users.
  • Followers: A user can be followed by other users.

Session Table

Description: Stores session information for users.
Column NameTypeConstraintsDescription
idtextPrimary KeyUnique session identifier.
userIdintegerNot Null, Foreign KeyReferences user.id.
expiresAttimestampNot NullTimestamp when the session expires.

Relationships

  • User: Each session is associated with one user.

Post Table

Description: Stores posts created by users.
Column NameTypeConstraintsDescription
idserialPrimary KeyUnique identifier for the post.
snowflakeIdbigintNot NullUnique identifier for the post (Snowflake ID).
userIdintegerNot Null, Foreign KeyReferences user.id.
contenttextContent of the post.
createdAttimestampNot Null, Default NowTimestamp when the post was created.
updatedAttimestampNot Null, Default NowTimestamp when the post was last updated.
typeenum post_typeNot NullType of the post (e.g., post, quote, reply,repost).
originalIdintegerForeign KeyReferences the original post if it’s a reply, repost or quote.
parentIdintegerForeign KeyReferences the parent post if it’s a reply, repost or quote.
hashtagstext[]Not Null, Default: empty arrayArray of hashtags associated with the post.
repliesCountintegerNot Null, Default: 0Number of replies to the post.
repostsCountintegerNot Null, Default: 0Number of reposts of the post.
repostsinteger[]Not Null, Default: empty arrayArray of userIds reposted.
isSuspendedbooleanNot Null, Default: falseIndicates if the user is suspended.

Relationships

  • User: Each post is created by one user.
  • Original Post: Posts can reference other posts as the original post.
  • Parent Post: Posts can reference other posts as the parent post.
  • Children: A post can have multiple child posts.
  • Media: Posts can have multiple media attachments.
  • Notifications: Posts can trigger notifications.
  • Links: Posts may have multiple links.

Post Child Table

This table is reserved only for Post type reply
Description: Stores the relationships between parent and child posts.
Column NameTypeConstraintsDescription
idserialPrimary KeyUnique identifier for the record.
parentIdintegerNot Null, Foreign KeyReferences the parent post.
childIdintegerNot Null, Foreign KeyReferences the child post.
typeenum post_typeNot NullType of the relationship.

Relationships

  • Parent Post: Each child record references a parent post.
  • Child Post: Each child record references a child post.

Post Media Table

Although there is no limit at the database level, we put a limit of 4 media files per post via backend validation.
Description: Stores media attachments for posts.
Column NameTypeConstraintsDescription
idserialPrimary KeyUnique identifier for the media.
postIdintegerNot Null, Foreign KeyReferences the post.
mediaUrltextNot NullURL of the media.
mimeTypetextNot NullMIME type of the media.
updatedAttimestampNot Null, Default NowTimestamp when the media was last updated.

Relationships

  • Post: Each media record is associated with one post.

Follow Table

Description: Stores follow relationships between users.
Column NameTypeConstraintsDescription
idserialPrimary KeyUnique identifier for the follow record.
followerIdintegerNot Null, Foreign KeyReferences the user who follows.
followedIdintegerNot Null, Foreign KeyReferences the user who is followed.

Relationships

  • Follower: Each follow record references a follower user.
  • Followed: Each follow record references a followed user.

Notification Table

Description: Stores notifications for users.
Column NameTypeConstraintsDescription
idserialPrimary KeyUnique identifier for the notification.
userIdintegerNot Null, Foreign KeyReferences the user who receives the notification.
actorIdintegerNot Null, Foreign KeyReferences the user who triggered the notification.
typeenum post_typeNot NullType of the notification (e.g., mention,follow, quote, reply,repost).
postIdintegerForeign KeyReferences the post associated with the notification.
createdAttimestampNot Null, Default NowTimestamp when the notification was created.
readbooleanNot Null, Default: falseIndicates whether the notification has been read.

Relationships

  • User: Each notification is associated with the user who receives it.
  • Actor: Each notification references the user who triggered it.
  • Post: Each notification can be associated with a post.

Description: Stores metadata for links shared in posts.
Column NameTypeConstraintsDescription
urltextPrimary KeyThe URL of the link.
titletextThe title of the linked content.
descriptiontextA description of the linked content.
imagetextURL of an image associated with the link.

Relationships

  • Post Links: A link can be associated with multiple posts.

Post Link Table

Description: Associates links with posts.
Column NameTypeConstraintsDescription
urltextNot Null, Foreign KeyReferences link.url.
postIdintegerNot Null, Foreign KeyReferences post.id.
userIdintegerNot Null, Foreign KeyReferences user.id.

Relationships

  • Post: Each post link record is associated with one post.
  • User: Each post link record is associated with one user.
  • Link: Each post link record references one link.

Report Table

Description: Stores reports made by users.
Column NameTypeConstraintsDescription
idserialPrimary KeyUnique identifier for the report.
reporterUserIdintegerNot Null, Foreign KeyReferences the user who made the report.
targetUserIdintegerNot Null, Foreign KeyReferences the user being reported.
targetPostIdintegerForeign KeyReferences the post being reported, if any.
reasonenum report_reasonNot NullReason for the report.
statusenum report_statusNot Null, Default: reviewingCurrent status of the report.
notestextAdditional notes about the report.
createdAttimestampNot Null, Default NowTimestamp when the report was created.
updatedAttimestampNot Null, Default NowTimestamp when the report was last updated.

Relationships

  • Reporter: Each report is associated with the user who made it.
  • Target User: Each report is associated with the user being reported.
  • Target Post: A report may be associated with a specific post.
  • Report Actions: A report can have multiple actions taken on it.

Report Reason & Status Enums

Refer to Enum & JSON list for more info

Report Action Table

Description: Stores actions taken on reports.
Column NameTypeConstraintsDescription
idserialPrimary KeyUnique identifier for the report action.
reportIdintegerNot Null, Foreign KeyReferences the associated report.
actionTakenenum report_statusNot NullThe action taken on the report.
actionTakenByintegerNot Null, Foreign KeyReferences the admin who took the action.
actionTakenAttimestampNot Null, Default NowTimestamp when the action was taken.
notestextAdditional notes about the action taken.

Relationships

  • Report: Each report action is associated with one report.
  • Admin: Each report action is associated with the admin who took the action.

Notes and Warnings

  • Ensure data integrity by using foreign key constraints to maintain relationships between tables.
  • Be cautious with unique and uniqueIndex constraints to avoid duplication issues.
  • Use appropriate data types for timestamps and enums to ensure compatibility and correct representation.