comments table
The comments table in the Social Media Database Schema schema has 9 columns, keyed by id, with 3 foreign keys to posts, users and comments. 3 columns in comment_likes, notifications and reports reference it.
Separate from posts on purpose: comments are never independently followable and never enter the fan-out feed.
Columns (9)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| post_id | uuid | not null, references posts.id | |
| author_id | uuid | not null, references users.id | |
| parent_comment_id | uuid | references comments.id | |
| body | varchar(2000) | not null | |
| like_count | integer | not null | |
| created_at | timestamptz | not null | |
| edited_at | timestamptz | ||
| deleted_at | timestamptz |
Indexes (2)
(post_id, created_at)(parent_comment_id)
Relationships
comments.post_idreferencesposts.idcomments.author_idreferencesusers.idcomments.parent_comment_idreferencescomments.idcomment_likes.comment_idreferencescommentsnotifications.comment_idreferencescommentsreports.comment_idreferencescomments