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)

Columns of the comments table
ColumnTypeConstraintsDescription
iduuidprimary key
post_iduuidnot null, references posts.id
author_iduuidnot null, references users.id
parent_comment_iduuidreferences comments.id
bodyvarchar(2000)not null
like_countintegernot null
created_attimestamptznot null
edited_attimestamptz
deleted_attimestamptz

Indexes (2)

  • (post_id, created_at)
  • (parent_comment_id)

Relationships