Another approach that allows group messaging too, and also using another parent table for chat sessions which may allow faster filtering:
Chats
-ChatId
ChatUsers
-ChatUserId
-ChatId(FK)
-UserId(FK)
ChatMessages
-ChatMessageId
-ChatUserId(FK)
-Msg
-Date and other meta
Addendum after watching the video that Lonare provides: Actually my approach is very similar to that schema. LastMessage and LastMessageUserId can be very effective additions.
发布评论
评论(3)
一张表出了什么问题?message_id
时间戳
到
从
主题
身体
附件指针
起源
...
我可能会因此而受到殴打,但是...
嗯...好点
编辑:还发现了这些:
消息系统数据库架构
线程消息传递系统数据库架构设计
我应该如何设置我的数据库带有附件的消息传递系统的架构?
用于向多个用户发送消息的数据库架构
What is wrong with one table?message_id
timestamp
to
from
subject
body
attachment_pointer
origin
...
I'll probably get thrashed for it but...
hmm...good point
edit: Also found these:
Messaging system database schema
thread messaging system database schema design
How should I setup my database schema for a messaging system complete with attachments?
Database schema for messaging to multiple users
您好,您可以使用连接表。这是一个非常简单的架构,许多巨头都在使用,例如 YouTube、Reddit 等。
这是视频解释了如何仅 2 个查询即可使您的应用上线。
Hi you can use a joining table. This is very simple architecture which lot of giants are using like YouTube, Reddit etc.
Here is a video explaining how only 2 queries will be bringing your app to live.
另一种方法也允许群组消息传递,并且还使用另一个父表进行聊天会话,这可能允许更快的过滤:
观看 Lonare 提供的视频后的附录:
实际上我的方法与该模式非常相似。 LastMessage 和 LastMessageUserId 是非常有效的补充。
Another approach that allows group messaging too, and also using another parent table for chat sessions which may allow faster filtering:
Addendum after watching the video that Lonare provides:
Actually my approach is very similar to that schema. LastMessage and LastMessageUserId can be very effective additions.