dongtun3328 2011-04-20 04:10
浏览 19
已采纳

编码线程多收件人邮件系统的最佳实践?

I've been tearing my hair out trying to figure out how to code a messaging system capable of the following:

  1. Multiple recipients, where the recipients can not see other recipients, but only the sender. In the sent messages, the sender sees messages sent to multiple recipients in one thread, rather than in a billion separate threads.
  2. Relatively lightweight queries (we have relatively 20,000 users - about 10% of which regularly send messages to 200-300 people at once).

Our current system is incredibly inefficient, and the queries are killing our servers with excessive joins. I'm looking for conceptual advice on crafting a scalable threaded messaging system in PHP and MySQL - what sort of database structure is best, how to store recipients, best practices for queries. Can anyone help?!

Thanks!

  • 写回答

2条回答 默认 最新

  • dsm13698679318 2011-04-20 04:20
    关注

    It seems like the place to start would simply be three tables, a recipient table, a message table and a message_recipient many to many mapping table. Something like this:

    recipient

    • recipient_id
    • name
    • email

    message

    • message_id
    • message_text

    message_recipient

    • message_id
    • recipient_id

    Be sure to creat an index on both fields of the message_recipient table, and then it becomes the focal point for all queries for messages.

    Have you tried anything like that approach? It's the simplest and most straightforward. If that doesn't work, it can probably be tuned.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100