polls table

The polls table in the Reddit Clone Database Schema schema has 5 columns, keyed by post_id. 2 columns in posts and poll_options reference it.

Keyed by post_id because a poll is not a separate object, it is a property of one post. ends_at is the only state a poll needs - open versus closed is a comparison, not a status column that can drift out of sync with the clock.

Columns (5)

Columns of the polls table
ColumnTypeConstraintsDescription
post_iduuidprimary key
total_vote_countintegernot null
allows_multiplebooleannot null
is_predictionbooleannot null
ends_attimestamptznot null

Relationships