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)
| Column | Type | Constraints | Description |
|---|---|---|---|
| post_id | uuid | primary key | |
| total_vote_count | integer | not null | |
| allows_multiple | boolean | not null | |
| is_prediction | boolean | not null | |
| ends_at | timestamptz | not null |
Relationships
posts.idreferencespollspoll_options.post_idreferencespolls