Answer the question
In order to leave comments, you need to log in
How to store correspondence in the database in this case?
I am writing a project in java. I chose mySql as the DBMS. There was a need to store correspondence between users. The program has only a 1:1 dialogue, no rooms and nothing like that. I think it is correct to store all correspondence in one table, but how to implement it correctly? Plus, I need to somehow generate a message history. From ideas I have the following:
|sender_login|recipient_login|message_text|additional_message_parameter|previous_message_number| .
But I don't like this construction for the reason that in order to add a new message, I need to know the number of the previous one. And suddenly users send a message at once, and what happens? that two messages under one number? How to generate SMS then? Have I made the table correctly?
Answer the question
In order to leave comments, you need to log in
No additional table. There is enough in the message table Код, кто, кому, время
to select a correspondence.
I will not know which SMS came firstThe one with
код
less, if you время
don't have enough precision.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question