Structuring Message/Messenger Data

I’m trying to determine the best way to structure the data for my messenging system. I’ve read through a number of forum posts and everyone does it a bit differently, but I want to create conversations with one or multiple users, with the message text on the left side for all received messages, and the text on the right side for sent messages.

Is it best to build this with a data type of “Conversation” for each conversation, which would contain multiple users and the message texts? Or is there a better method?

Do the following:

Table 1 = Conversation
Fields:

  • parties (list of users)
  • see convo (list of users)

Table 2 = Message
Fields:

  • Conversation (Conversation)
  • parties (list of users)
  • see message (list of users)
  • sender (user)
  • recipients (list of users) If you are never going to use group messaging, then this can just be 1 user
  • text (text)

You could also add a “read” field which would be a list of users who have read the message.

Let me know if you need me to explain any of this,
Daniel

2 Likes

Thanks @dbevan! I may shoot you a message if I have questions!

1 Like

No problem! I’d be happy to help.