drafts table

The drafts table in the Reddit Clone Database Schema schema has 12 columns, keyed by id, with 3 foreign keys to users, subreddits and flairs. 1 column in scheduled_posts references it.

A draft is not an unpublished post. It carries no scores, no counters and no subreddit requirement, which is why it is its own table rather than a status on posts.

Columns (12)

Columns of the drafts table
ColumnTypeConstraintsDescription
iduuidprimary key
author_iduuidnot null, references users.id
subreddit_iduuidreferences subreddits.id
kindpost_kindnot null
titlevarchar(300)
body_mdtext
urlvarchar(2000)
flair_iduuidreferences flairs.id
is_nsfwbooleannot null
is_spoilerbooleannot null
created_attimestamptznot null
updated_attimestamptznot null

Indexes (1)

  • (author_id, updated_at)

Relationships