Echusen
Echusen

Reputation: 361

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.

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.

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.

Upvotes: 1

Views: 441

Answers (1)

Kombajn zbożowy
Kombajn zbożowy

Reputation: 10693

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. 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.

Upvotes: 1

Related Questions