posts table

The posts table in the Social Media Database Schema schema has 14 columns, keyed by id, with 3 foreign keys to users, posts and groups. 12 columns in post_media, post_hashtags, post_mentions, post_likes and 8 more reference it.

Self-referencing for threads. The three count columns are denormalised caches, rebuildable from the engagement tables. deleted_at is a soft delete so replies do not orphan.

Columns (14)

Columns of the posts table
ColumnTypeConstraintsDescription
iduuidprimary key
author_iduuidnot null, references users.id
parent_post_iduuidreferences posts.id
group_iduuidreferences groups.id
typepost_typenot null
visibilitypost_visibilitynot null
bodyvarchar(2000)
languagechar(2)
reply_countintegernot null
like_countintegernot null
repost_countintegernot null
created_attimestamptznot null
edited_attimestamptz
deleted_attimestamptz

Indexes (4)

  • (author_id, created_at)
  • (parent_post_id)
  • (group_id, created_at)
  • (visibility, created_at)

Relationships