chat_messages table
The chat_messages table in the Reddit Clone Database Schema schema has 9 columns, keyed by id, with 4 foreign keys to chat_channels, users, chat_messages and media_assets. 2 columns in chat_channel_members and chat_reactions reference it.
Columns (9)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| channel_id | uuid | not null, references chat_channels.id | |
| author_id | uuid | references users.id | |
| reply_to_id | uuid | references chat_messages.id | |
| body | text | not null | |
| media_asset_id | uuid | references media_assets.id | |
| created_at | timestamptz | not null | |
| edited_at | timestamptz | ||
| deleted_at | timestamptz |
Indexes (2)
(channel_id, created_at)(author_id, created_at)
Relationships
chat_messages.channel_idreferenceschat_channels.idchat_messages.author_idreferencesusers.idchat_messages.reply_to_idreferenceschat_messages.idchat_messages.media_asset_idreferencesmedia_assets.idchat_channel_members.last_read_message_idreferenceschat_messageschat_reactions.message_idreferenceschat_messages