flairs table
The flairs table in the Reddit Clone Database Schema schema has 11 columns, keyed by id, with 1 foreign key to subreddits. 3 columns in user_flairs, posts and drafts reference it.
Flair is a row scoped to one subreddit, not free text on the post. That is what lets a community offer a fixed set, mark some mod-only, and rename one everywhere at once.
Columns (11)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| subreddit_id | uuid | not null, references subreddits.id | |
| type | flair_type | not null | |
| text | varchar(64) | not null | |
| background_color | char(7) | ||
| text_color | varchar(10) | ||
| allowable_content | flair_content | not null | |
| max_emojis | smallint | not null | |
| is_mod_only | boolean | not null | |
| is_editable | boolean | not null | |
| position | smallint | not null |
Indexes (1)
(subreddit_id, type, position)
Relationships
flairs.subreddit_idreferencessubreddits.iduser_flairs.flair_idreferencesflairsposts.flair_idreferencesflairsdrafts.flair_idreferencesflairs