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)

Columns of the award_gifts table
ColumnTypeConstraintsDescription
iduuidprimary key
award_iduuidnot null, references awards.id
giver_iduuidreferences users.id
receiver_iduuidnot null, references users.id
content_typecontent_typenot null
content_iduuidnot null
coins_spentintegernot null
is_anonymousbooleannot null
messagevarchar(500)
created_attimestamptznot null

Indexes (3)

  • (content_type, content_id)
  • (receiver_id, created_at)
  • (giver_id, created_at)

Relationships

  • award_gifts.award_id references awards.id
  • award_gifts.giver_id references users.id
  • award_gifts.receiver_id references users.id