Facebook风格的消息系统架构设计
我正在寻找在我的网站中实现 Facebook 风格的消息系统(线程消息)。
您认为这个架构标记看起来还好吗?
Doctrine schema.yml:
UserMessage:
tableName: user_message
actAs: [Timestampable]
columns:
id: { type: integer(10), primary: true, autoincrement: true }
sender_id : { type: integer(10), notnull: true }
sender_read: { type: boolean, default: 1 }
subject: { type: string(255), notnull: true }
message: { type: string(1000), notnull: true }
hash: { type: string(32), notnull: true }
relations:
UserMessageRecipient as Recipient:
type: many
local: id
foreign: message_id
UserMessageReply as Reply:
type: many
local: id
foreign: message_id
UserMessageReply:
tableName: user_message_reply
columns:
id: { type: integer(10), primary: true, autoincrement: true }
user_message_id as message_id: { type: integer(10), notnull: true }
message: { type: string(1000), notnull: true }
sender_id: { type: integer(10), notnull: true }
relations:
UserMessage as Message:
local: message_id
foreign: id
type: one
UserMessageRecipient:
tableName: user_message_recipient
actAs: [Timestampable]
columns:
id: { type: integer(10), primary: true, autoincrement: true }
user_message_id as message_id: { type: integer(10), notnull: true }
recipient_id: { type: integer(10), notnull: true }
recipient_read: { type: boolean, default: 0 }
当我做出新回复时,我将确保“recipient_read”的布尔值对于每个收件人都设置为 false,当然我会确保 sender_read 也设置为 false。
我使用 URL 的哈希值: http://example.com/user/messages/aadeb18f8bdaea49882ec4d2a8a3c062< /a>
(由于 id 将从 1 开始,我不希望有 http:// example.com/user/messages/1。是的,我可以从更大的数字开始递增,但我更愿意从 1 开始。)
这是一个好方法吗?我们将非常感谢您的想法和建议。
谢谢你们!
I'm looking to implement a facebook style messaging system (thread messages) into a site of mine.
Do you think this schema markup looks okay?
Doctrine schema.yml:
UserMessage:
tableName: user_message
actAs: [Timestampable]
columns:
id: { type: integer(10), primary: true, autoincrement: true }
sender_id : { type: integer(10), notnull: true }
sender_read: { type: boolean, default: 1 }
subject: { type: string(255), notnull: true }
message: { type: string(1000), notnull: true }
hash: { type: string(32), notnull: true }
relations:
UserMessageRecipient as Recipient:
type: many
local: id
foreign: message_id
UserMessageReply as Reply:
type: many
local: id
foreign: message_id
UserMessageReply:
tableName: user_message_reply
columns:
id: { type: integer(10), primary: true, autoincrement: true }
user_message_id as message_id: { type: integer(10), notnull: true }
message: { type: string(1000), notnull: true }
sender_id: { type: integer(10), notnull: true }
relations:
UserMessage as Message:
local: message_id
foreign: id
type: one
UserMessageRecipient:
tableName: user_message_recipient
actAs: [Timestampable]
columns:
id: { type: integer(10), primary: true, autoincrement: true }
user_message_id as message_id: { type: integer(10), notnull: true }
recipient_id: { type: integer(10), notnull: true }
recipient_read: { type: boolean, default: 0 }
When I a new reply is made,i'll make sure the boolean for "recipient_read" for each recipient is set to false and of course i'll make sure sender_read is set to false too.
I'm using a hash for the URL: http://example.com/user/messages/aadeb18f8bdaea49882ec4d2a8a3c062
(As the id will be starting from 1, i don't wish to have http://example.com/user/messages/1. Yeah, I could start incrementing from a bigger number, but i'd prefer to start at 1.)
Is this a good way to go about it? Your thoughts and suggestions would be hugely appreciated.
Thanks guys!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个型号怎么样?
What about this model?
user_message.created_at 和 user_message_recipient.created_at 有什么区别?
update_at 也有同样的问题。 (后来:我猜 user_message_recipient.updated_at 可能是收件人阅读消息的时间。如果是这样的话,我更喜欢一个更有意义的名称。)
您是否考虑过深入研究一些开源项目的源代码,这些项目旨在脸书替代品?
我希望这意味着 dbms 将验证这些布尔值是否设置正确。
What's the difference between user_message.created_at and user_message_recipient.created_at?
Same question for updated_at. (Later: I guess user_message_recipient.updated_at might be the time the recipient read the message. If that's the case, I'd prefer a more meaningful name.)
Did you consider digging into some source code for open source projects that are intended to be Facebook replacements?
I hope that means the dbms will verify those Booleans are set correctly.
我还尝试使用数据库创建一个消息系统,最常见的缺陷是忘记每个用户都有不同的已读-未读消息状态。我几乎没有在数据库方案中显示,但简而言之,您必须考虑为每个用户的每个 user_message 和 user_message_reply 创建类似 isread 的标志,这样每个用户只会看到未读消息。
i also tried to create a message system using database, the most common flaw is forgot that every user have different state of read-unread message. i hardly showing in database scheme, but in short you must consider to create flag like isread for every user for every user_message and user_message_reply, so every user just see the unread message.