notifications table
The notifications table in the Social Media Database Schema schema has 8 columns, keyed by id, with 4 foreign keys to users, posts and comments.
actor_id null is a system notification. The partial index on unread is what keeps the badge count cheap.
Columns (8)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| user_id | uuid | not null, references users.id | |
| actor_id | uuid | references users.id | |
| type | notification_type | not null | |
| post_id | uuid | references posts.id | |
| comment_id | uuid | references comments.id | |
| is_read | boolean | not null | |
| created_at | timestamptz | not null |
Indexes (1)
(user_id, is_read, created_at)
Relationships
notifications.user_idreferencesusers.idnotifications.actor_idreferencesusers.idnotifications.post_idreferencesposts.idnotifications.comment_idreferencescomments.id