user_preferences table
The user_preferences table in the Reddit Clone Database Schema schema has 13 columns, keyed by user_id. 1 column in users references it.
default_sort is why sort_order is an enum rather than a query string constant: the chosen listing order is persisted state, not a UI detail. Every column here is read on the first render of every page, which is why it is a narrow table split away from the profile.
Columns (13)
| Column | Type | Constraints | Description |
|---|---|---|---|
| user_id | uuid | primary key | |
| default_sort | sort_order | not null | |
| default_comment_sort | sort_order | not null | |
| theme | theme_preference | not null | |
| language | varchar(12) | not null | |
| show_nsfw | boolean | not null | |
| blur_nsfw_thumbnails | boolean | not null | |
| search_includes_nsfw | boolean | not null | |
| autoplay_media | boolean | not null | |
| reduce_animations | boolean | not null | |
| open_links_in_new_tab | boolean | not null | |
| mark_messages_read_on_open | boolean | not null | |
| email_digest_enabled | boolean | not null |
Relationships
users.idreferencesuser_preferences