mentions table
The mentions table in the Reddit Clone Database Schema schema has 6 columns, keyed by id, with 2 foreign keys to users and subreddits.
Mentions are extracted once at write time, so the mentions tab is an index lookup instead of a text scan across every comment ever written.
Columns (6)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| content_type | content_type | not null | |
| content_id | uuid | not null | |
| mentioned_user_id | uuid | references users.id | |
| mentioned_subreddit_id | uuid | references subreddits.id | |
| created_at | timestamptz | not null |
Indexes (2)
(mentioned_user_id, created_at)(content_type, content_id)
Relationships
mentions.mentioned_user_idreferencesusers.idmentions.mentioned_subreddit_idreferencessubreddits.id