topics table

The topics table in the Forum Database Schema schema has 15 columns, keyed by id, with 3 foreign keys to forums and users. 6 columns in topic_tags, posts, topic_subscriptions, topic_views and 2 more reference it.

The thread container. The composite index on forum, pinned and last_post_at IS the board listing query — pinned first, then most recent activity.

Columns (15)

Columns of the topics table
ColumnTypeConstraintsDescription
iduuidprimary key
forum_iduuidnot null, references forums.id
author_iduuidnot null, references users.id
slugvarchar(200)not null
titlevarchar(255)not null
statustopic_statusnot null
is_pinnedbooleannot null
is_answeredbooleannot null
accepted_post_iduuid
reply_countintegernot null
view_countintegernot null
vote_scoreintegernot null
last_post_attimestamptz
last_post_user_iduuidreferences users.id
created_attimestamptznot null

Indexes (4)

  • (forum_id, is_pinned, last_post_at)
  • (forum_id, slug) unique
  • (author_id, created_at)
  • (status, vote_score)

Relationships