posts table

The posts table in the Forum Database Schema schema has 11 columns, keyed by id, with 3 foreign keys to topics, users and posts. 5 columns in post_revisions, votes, topic_subscriptions, reports and 1 more reference it.

is_first_post marks the opening body of the thread, so the topic row never has to carry text. deleted_at is a soft delete so replies below it do not orphan.

Columns (11)

Columns of the posts table
ColumnTypeConstraintsDescription
iduuidprimary key
topic_iduuidnot null, references topics.id
author_iduuidnot null, references users.id
reply_to_post_iduuidreferences posts.id
bodytextnot null
vote_scoreintegernot null
is_first_postbooleannot null
edit_countsmallintnot null
created_attimestamptznot null
edited_attimestamptz
deleted_attimestamptz

Indexes (2)

  • (topic_id, created_at)
  • (author_id, created_at)

Relationships