subreddit_bans table

The subreddit_bans table in the Reddit Clone Database Schema schema has 12 columns, keyed by id, with 5 foreign keys to subreddits, users and subreddit_rules. 1 column in ban_appeals references it.

A ban is a row with an expiry, never a boolean. expires_at null is permanent, lifted_at records an early unban, and both together mean the sanction history survives an appeal. mod_note is private to moderators; message_to_user is what the person actually receives.

Columns (12)

Columns of the subreddit_bans table
ColumnTypeConstraintsDescription
iduuidprimary key
subreddit_iduuidnot null, references subreddits.id
user_iduuidnot null, references users.id
banned_byuuidnot null, references users.id
rule_iduuidreferences subreddit_rules.id
reasonvarchar(500)not null
mod_notevarchar(1000)
message_to_uservarchar(1000)
starts_attimestamptznot null
expires_attimestamptz
lifted_attimestamptz
lifted_byuuidreferences users.id

Indexes (2)

  • (subreddit_id, user_id, expires_at)
  • (user_id)

Relationships