messages table

The messages table in the Reddit Clone Database Schema schema has 9 columns, keyed by id, with 3 foreign keys to users and messages.

Private messages between two people, threaded by parent_id. Kept apart from modmail because a message to a person and a message to a moderator team are different objects with different read semantics.

Columns (9)

Columns of the messages table
ColumnTypeConstraintsDescription
iduuidprimary key
sender_iduuidreferences users.id
recipient_iduuidnot null, references users.id
parent_iduuidreferences messages.id
subjectvarchar(200)not null
body_mdtextnot null
created_attimestamptznot null
read_attimestamptz
deleted_attimestamptz

Indexes (3)

  • (recipient_id, created_at)
  • (recipient_id, read_at)
  • (parent_id)

Relationships