Architecture Database

Asked

Viewed 45 times

0

I have a question regarding the database. I have an X user who will be able to forward a message to N other user. What is the best way of this type of relationship? Should I create a table and insert each User (id) recipient together with the User(id) who sent it?

  • 1

    I guess so, but it’s hard to tell with just that.

  • In fact at first it will be just that in the same table xD kkk

  • So there’s no doubt?

  • @bigown think what he’s trying to explain would be like a communication system in an app, where an administrator triggers a message to all members.

1 answer

1

Thinking of a very simple scenario, would do in only 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 complicating the situation, depending on the number of recipients, etc... then it should be done in two tables to maintain the normal form and have no redundant data.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.