HDFilmMaker2112 Posted November 15, 2011 Share Posted November 15, 2011 Looking for the best way to set-up the db of a messaging system. Here's what I have so far (basically pulled from another forum), don't know if Table1 is even really necessary: Table1: id user_message_id recepient_id recepient_read Table2: user_message_id sender_id sender_read subject message created_at updated_at Basically it needs to function where, someone submits a message to the admin or moderator, the admin/moderators can review and reply, and then the user can submit another reply, and keeps going indefinitely. I want each reply to show up almost like a forum thread. How would I chain the reply messages to the original messages? Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted November 15, 2011 Share Posted November 15, 2011 you only need 1 table, and to 'chain' them, that's just a matter of using the correct SQL SELECT statement. Quote Link to comment Share on other sites More sharing options...
HDFilmMaker2112 Posted November 15, 2011 Author Share Posted November 15, 2011 But say I have the following: Situation 1: User 2 submits a message -> admin 1 sees it and replies to user 2 -> user 2 replies to the message from admin 1 -> moderator 3 sees the message from user 2 and replies. Situation 2: user 4 submits a message -> moderator 5 sees it and replies to user 4 -> user 4 replies to the message from moderator 5 -> admin 1 sees reply from user 4 and moderator 5, and replies to user 4 about the topic and messages moderator 5 to let them know something they told user 4 was incorrect. How would all of that be chained together with a simple SELECT statement? I would need to select say message id numbers in situation 1: 123234 123453 123454 123544 and then loop them, to display them. And then in situation 2 message id numbers: 342342 342346 342356 342643 342678 Quote Link to comment Share on other sites More sharing options...
HDFilmMaker2112 Posted November 15, 2011 Author Share Posted November 15, 2011 Here's what I came up with: Conversation Number: id conversation_id message_number Message: message_number user_id username name message conversation_id Could that be simplified? If so how? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.