How to describe the database of a chat with multiple people

Asked

Viewed 1,005 times

3

That it’s easy to make a conversation between two people, I know, but then someone can quote an example of how to make a group conversation? With an unlimited number of people.

Conversation between 2 people:

TABELA MYSQL

|   De    |     Para      |   Mensagem   |


|  User1  |     User2     |     Olá      |

Does anyone have a different idea for adding more people to this conversation?

  • 2

    a message for all users could use the column for as null for example.

1 answer

3


Or so:

Table:
| Channel |  who                   | message |
|  #uno   | [nick1, nick2, nick3]  |   Olá   |

Or:

| sender | receiver                | message |
|  nick1 | [nick2, nick3, nick 4]  |   Olá   |

Or else

| id | Channel | who                  |
|  0 | #uno    | [nick1, nick2, ... ] |
----------------------------------
| sender  | toChannel | message |
|  nick1  | 0         |   Olá   |

The possibilities are literally endless; What you have to worry about is having a list of receivers of the message, and looping "while I haven’t sent to this, send, otherwise take it off this list"

  • I liked the third answer, the view is very effective, thank you! :)

Browser other questions tagged

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