T
T
TopMetaFizick_0102019-03-12 12:55:57
Database design
TopMetaFizick_010, 2019-03-12 12:55:57

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

2 answer(s)
K
Konstantin Tsvetkov, 2019-03-12
@TopMetaFizick_010

No additional table. There is enough in the message table Код, кто, кому, времяto select a correspondence.

I will not know which SMS came first
The one with кодless, if you времяdon't have enough precision.

R
Rsa97, 2019-03-12
@Rsa97

Why do you need a number? What prevents to use timestamp?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question