comments table
The comments table in the Blog Database Schema schema has 11 columns, keyed by id, with 3 foreign keys to posts, comments and users. 1 column in comment_reports references it.
user_id null is a guest comment, which is why the author name and email are denormalised here. Self-referencing for threads.
Columns (11)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| post_id | uuid | not null, references posts.id | |
| parent_id | uuid | references comments.id | |
| user_id | uuid | references users.id | |
| author_name | varchar(120) | ||
| author_email | varchar(255) | ||
| author_url | varchar(255) | ||
| body | text | not null | |
| status | comment_status | not null | |
| ip_address | varchar(45) | ||
| created_at | timestamptz | not null |
Indexes (3)
(post_id, status, created_at)(parent_id)(status, created_at)
Relationships
comments.post_idreferencesposts.idcomments.parent_idreferencescomments.idcomments.user_idreferencesusers.idcomment_reports.comment_idreferencescomments