chat_channels table
The chat_channels table in the Reddit Clone Database Schema schema has 10 columns, keyed by id, with 2 foreign keys to subreddits and users. 2 columns in chat_channel_members and chat_messages reference it.
One table for direct chats, group chats, community channels and mod team rooms, distinguished by kind. They differ only in who may join, which is membership, not structure.
Columns (10)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| subreddit_id | uuid | references subreddits.id | |
| kind | chat_channel_kind | not null | |
| name | varchar(100) | ||
| topic | varchar(500) | ||
| created_by | uuid | references users.id | |
| is_private | boolean | not null | |
| member_count | integer | not null | |
| last_message_at | timestamptz | ||
| created_at | timestamptz | not null |
Indexes (2)
(subreddit_id, kind)(kind, last_message_at)
Relationships
chat_channels.subreddit_idreferencessubreddits.idchat_channels.created_byreferencesusers.idchat_channel_members.channel_idreferenceschat_channelschat_messages.channel_idreferenceschat_channels