chat_channel_members table

The chat_channel_members table in the Reddit Clone Database Schema schema has 6 columns, with 3 foreign keys to chat_channels, users and chat_messages.

last_read_message_id is a high-water mark, not a row per message read. Unread count is a cheap range query above it, which is the only way a chat badge stays fast.

Columns (6)

Columns of the chat_channel_members table
ColumnTypeConstraintsDescription
channel_iduuidnot null, references chat_channels.id
user_iduuidnot null, references users.id
rolechat_member_rolenot null
last_read_message_iduuidreferences chat_messages.id
is_mutedbooleannot null
joined_attimestamptznot null

Indexes (1)

  • (user_id, joined_at)

Relationships