coin_balances table

The coin_balances table in the Reddit Clone Database Schema schema has 6 columns, keyed by user_id. 1 column in users references it.

A cached running total. The truth is coin_transactions, and this row can always be rebuilt by summing it. users.coin_balance mirrors this again for the header badge, because that number is read on literally every page.

Columns (6)

Columns of the coin_balances table
ColumnTypeConstraintsDescription
user_iduuidprimary key
balanceintegernot null
lifetime_purchasedintegernot null
lifetime_earnedintegernot null
lifetime_spentintegernot null
updated_attimestamptznot null

Relationships