Architecture Database

0

I have a question regarding the database. I have an X user who will be able to forward a message to other N users. What is the best form of this type of relationship? Should I create a table and enter each recipient (id) along with the user (id) that you sent?

    
asked by anonymous 12.07.2017 / 00:35

1 answer

1

Thinking about a very simple scenario, I would do it in just one table:

Mensagens
id   |   data        |   remetente  | destinatário  | mensagem  | lida
 1       01/01/2017             1      2               Teste       false
 2       01/01/2017             1      3               Teste       true
 3       01/01/2017             1      4               Teste       false
 4       01/01/2017             1      5               Teste       true
 5       01/01/2017             1      6               Teste       false

But if it complicates the situation, depending on the number of recipients, etc ... it should be done in two tables to maintain the normal form and not have redundant data.

    
12.07.2017 / 00:55