Jump to content

Recommended Posts

Posted

I'm having a hard time figuring out the logic for creating a private messaging system that allows for more than 2 participants.

 

What kind of database setup could I use to do this?

 

I don't want to have a table with field for "user1", "user2", "user3", etc. because it strikes me as terribly inefficient and just messed up. How can I store the users of a conversation?

 

Maybe have a table for conversations, messages, and participants? Then all the users inside the participants table that are filed under the specific conversation ID are allowed to access? Would there be a way to do it with only two tables?

 

What do you think is the most efficient way to accomplish this task?

  • Administrators
Posted

I would do something like this:

convo
id
convo
createDate
convoOwnerID

messages
id
convoID
message
createDate
messageOwnerID


convoParticipants
id
userID
convoID
hasRead
Posted

 

I would do something like this:

convo
id
convo
create_date
convo_owner_id

messages
id
convo_id
message
create_date
message_owner_id

convo_participants
id
user_id
convo_id

 

I think XenForo does something similar to this for their conversation system.

 

Seems to work pretty good.

 

Thanks for the suggestion!

  • 4 years later...
Posted
On 2/20/2015 at 9:31 PM, Nathan said:

I would do something like this:


convo
id
convo
createDate
convoOwnerID

messages
id
convoID
message
createDate
messageOwnerID


convoParticipants
id
userID
convoID
hasRead

Thanks for your valuable answer. It would be helpful to me.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...