简体   繁体   English

收件箱/邮件数据模型

[英]Inbox/Messaging data model

I'm working on a project to be specific is a website wherein there is an inbox or messaging where users can send messages to other users. 我正在研究的项目是一个网站,其中有一个收件箱或消息传递,用户可以将消息发送给其他用户。

I'm just looking over the net how to create a data model for this, could you help me on this one. 我只是在网上寻找如何为此创建数据模型,您能帮我这个忙吗? What I did at first is every text or message that they will try to enter will be inserted to database table which I think inappropriate because what if there are for example 10,000 users, imagine the table for messaging will be huge. 首先,我所做的是将他们尝试输入的所有文本或消息都插入到数据库表中,我认为这是不合适的,因为如果有10,000个用户,那么可以想象用于消息传递的表将是巨大的。

Is there any approach that you would suggest on this one. 您对此有何建议?

Here's the approach I did. 这是我做的方法。

User sender sent msg --> INSERT msg INTO TABLE message --> User receiver reply --> INSERT reply INTO TABLE message. 用户发送方发送了msg-> INSERT msg INTO TABLE消息->用户接收方回复-> INSERT回复INTO TABLE消息。

In this kind of approach the table "message" will have lots of data on it and imagine if there are 10,000 users sending messages. 通过这种方法,表“ message”上将有大量数据,并假设是否有10,000个用户在发送消息。

If your need is to store users' messages and the amount of messages is large, the data (whatever organized it could be) will be large. 如果您需要存储用户的消息并且消息量很大,那么数据(无论它是如何组织的) 都会很大。 But this is the purpose of the database to store data. 但这数据库存储数据的目的。 Your approach is the simplest and most efficient. 您的方法是最简单,最有效的。 Nothing wrong with it. 没错。 The messages table with one record per message seems to be proper and relational way. 消息表每条消息一条记录似乎是正确的和相关的方式。

Think of the numbers. 想想数字。 Even if every user sends 10 messages a day (how likely is this?), it makes 100k records a day or 36M a year. 即使每个用户每天发送10条消息(可能性有多大?),每天也要进行10万条记录,一年也要进行3600万条记录。 It's not really a huge amount. 这不是一个很大的数目。

Design indexing carefully and it should be fine. 仔细设计索引编制,应该没问题。 With long-term planning you may go for compression, partitioning (if your database supports it) and pruning/archiving of old messages. 通过长期规划,您可能会进行压缩,分区(如果数据库支持)以及对旧消息进行修剪/归档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM