Jump to content
KenBrace

How to create private messaging system with multiple participants?

Recommended Posts

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?

Share this post


Link to post
Share on other sites

 

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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×