User Preference Data Model
What you'll learn: How to design a database schema that captures each user's notification preferences across channels, frequency, and opt-out choices.
Why User Preferences Matter
A notification system without user control quickly becomes spam. Your data model must store granular preferences so users can choose what notifications they receive, how often, and through which channels. Think of it like a restaurant menu where each diner marks exactly what they want, don't want, and any dietary restrictions.
Core Schema Components
Your user preference table needs to capture multiple dimensions:
1. User Identification
user_id (PK)
2. Channel-Specific Toggles
enable_push: boolean
enable_email: boolean
enable_sms: boolean
enable_in_app: boolean
3. Category-Level Controls Each notification type (marketing, alerts, social) should be toggleable:
category: string (e.g., "order_updates", "marketing", "security")
enabled: boolean
4. Frequency Preferences
frequency: enum (instant, hourly_digest, daily_digest, weekly)
quiet_hours_start: time
quiet_hours_end: time
timezone: string
5. Global Opt-Out
global_opt_out: boolean
opted_out_at: timestamp
Schema Design Pattern
Many systems use a hybrid approach: a base user_preferences table with defaults, plus a user_notification_settings table with rows per category-channel combination. This allows fine-grained control (turn off email for marketing but keep push) without a massive wide table.
Key Takeaway: Design your preference schema with per-channel, per-category granularity, include frequency controls and quiet hours, and always provide a global opt-out—users who feel in control engage more positively with your notifications.