user_trophies table
The user_trophies table in the Reddit Clone Database Schema schema has 5 columns, with 4 foreign keys to users, trophies and subreddits.
subreddit_id is part of the key because a community trophy can be earned once per community, while a site trophy is earned once overall with a null there.
Columns (5)
| Column | Type | Constraints | Description |
|---|---|---|---|
| user_id | uuid | not null, references users.id | |
| trophy_id | uuid | not null, references trophies.id | |
| subreddit_id | uuid | references subreddits.id | |
| granted_by | uuid | references users.id | |
| awarded_at | timestamptz | not null |
Indexes (1)
(trophy_id)
Relationships
user_trophies.user_idreferencesusers.iduser_trophies.trophy_idreferencestrophies.iduser_trophies.subreddit_idreferencessubreddits.iduser_trophies.granted_byreferencesusers.id