award_gifts table
The award_gifts table in the Reddit Clone Database Schema schema has 10 columns, keyed by id, with 3 foreign keys to awards and users.
One row per gift, never a counter on the post, so the award strip can be rebuilt and a refund is one delete. is_anonymous is a display flag - the giver is still recorded, because an abusive award message has to be traceable.
Columns (10)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| award_id | uuid | not null, references awards.id | |
| giver_id | uuid | references users.id | |
| receiver_id | uuid | not null, references users.id | |
| content_type | content_type | not null | |
| content_id | uuid | not null | |
| coins_spent | integer | not null | |
| is_anonymous | boolean | not null | |
| message | varchar(500) | ||
| created_at | timestamptz | not null |
Indexes (3)
(content_type, content_id)(receiver_id, created_at)(giver_id, created_at)