Answer the question
In order to leave comments, you need to log in
How to implement the storage of messages in a social network?
Good time of the day! Decided to write a social network for practice, the issue of efficient storage of messages (especially in "conversations") was taken by surprise.
If you store data in a database (mysql), a problem immediately arises: if a person wants to delete messages, they should be deleted only from him, and not from all interlocutors. It turns out that either you need to add to each message a list of those who deleted it, or create a separate copy of the message for each person initially in order to delete the message only from him at the right time. Obviously, the first method is simply terrible, and the second creates either a blockage in the database with messages, where there will be a bunch of copies of them, or forces you to create separate databases for storing messages for each user. As far as I know, doing this in mysql is very inefficient: it slows down performance and forces you to make "unusual" database queries.
Therefore, I came to the conclusion that in the database, in my case, it is best to store only general data about the dialogue (conversation), and to store messages, use XML files that will be in the user's folder. If he wants to delete the message / dialog, the changes will only affect his file, but not the files of other users. Then, when a new message appears, you will need to update the XML file for each of the participants in the dialogue (conversation). Is it expensive in terms of resources, and won't it be slow (frequent work with such files)? And in the case of a conversation (which will, for example, be 30 people), isn't it stupid to use a similar model in which we will save a copy of each message in the XML file of each participant?
What will be the load? How many users?
- Soc. network for practice, there will be no users, I just want to implement the necessary structure as efficiently as possible, as it could be in a real project.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question