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)

Columns of the comments table
ColumnTypeConstraintsDescription
iduuidprimary key
post_iduuidnot null, references posts.id
parent_iduuidreferences comments.id
user_iduuidreferences users.id
author_namevarchar(120)
author_emailvarchar(255)
author_urlvarchar(255)
bodytextnot null
statuscomment_statusnot null
ip_addressvarchar(45)
created_attimestamptznot null

Indexes (3)

  • (post_id, status, created_at)
  • (parent_id)
  • (status, created_at)

Relationships