scheduled_posts table

The scheduled_posts table in the Reddit Clone Database Schema schema has 10 columns, keyed by id, with 4 foreign keys to drafts, subreddits, users and posts.

The index on (status, scheduled_for) IS the scheduler: one range scan finds everything due. recurrence lets a mod team post a weekly thread without a cron job per community.

Columns (10)

Columns of the scheduled_posts table
ColumnTypeConstraintsDescription
iduuidprimary key
draft_iduuidreferences drafts.id
subreddit_iduuidnot null, references subreddits.id
author_iduuidnot null, references users.id
scheduled_fortimestamptznot null
recurrencerecurrence_kindnot null
statusschedule_statusnot null
published_post_iduuidreferences posts.id
last_errorvarchar(500)
created_attimestamptznot null

Indexes (2)

  • (status, scheduled_for)
  • (subreddit_id, scheduled_for)

Relationships

  • scheduled_posts.draft_id references drafts.id
  • scheduled_posts.subreddit_id references subreddits.id
  • scheduled_posts.author_id references users.id
  • scheduled_posts.published_post_id references posts.id