Katten Posted September 24, 2012 Share Posted September 24, 2012 What is the best practice for creating a private message system for... say a forum? I was thinking you just create a Message table, insert all messages into there and other info such as user id, when someone goes to view messages they can only view them based on their corresponding id. But maybe this one table approach isn't the way to go, just looking for suggestions or advice. -thanks! Quote Link to comment https://forums.phpfreaks.com/topic/268724-private-message-system-for-forum/ Share on other sites More sharing options...
Psycho Posted September 24, 2012 Share Posted September 24, 2012 (edited) The solution will be based upon the features you want to support in this messaging system. If all you need is a "basic" system with sender/receiver ids, text of the message, date sent, and possibly a flag to determine if it has been viewed/read, then a single table is perfectly apprpriate and probably the best approach. Edited September 24, 2012 by Psycho Quote Link to comment https://forums.phpfreaks.com/topic/268724-private-message-system-for-forum/#findComment-1380481 Share on other sites More sharing options...
Hall of Famer Posted September 24, 2012 Share Posted September 24, 2012 (edited) Well in my application the private message database table stores the following info: mid: Message ID sender: The sender's info recipient: The recipient's info title: Message Title text: Message Context datesent: The date message is sent status: Unread or Read(users are notified by unread messages from a widget at sidebar) folder: The folder a private message is stored in. Can be Inbox, Outbox, Draft or user created folders So yeah, it really depends on how complex your PM system is gonna be. You can start off with a simple design, but make sure it is extensible and reusable so you can add new features every now and then. If you have other types of messages such as Visitor Message(profile comment), Shoutbox Message and System Message, it will be a good idea to use strategy design pattern. Edited September 24, 2012 by Hall of Famer Quote Link to comment https://forums.phpfreaks.com/topic/268724-private-message-system-for-forum/#findComment-1380498 Share on other sites More sharing options...
Katten Posted September 24, 2012 Author Share Posted September 24, 2012 Alright thanks for the advice! Psycho you were saying that would be for simple or basic systems but out of curiosity what would you do for more complex pm systems? Quote Link to comment https://forums.phpfreaks.com/topic/268724-private-message-system-for-forum/#findComment-1380523 Share on other sites More sharing options...
Psycho Posted September 24, 2012 Share Posted September 24, 2012 Alright thanks for the advice! Psycho you were saying that would be for simple or basic systems but out of curiosity what would you do for more complex pm systems? The answer is "It depends". It cannot be answered without knowing what data would need to be stored for that complext system. I think you are missing the point of how to detemine the database structure. The data to be stored and the logical association of that data should determine what the structure is. So, you can't just say something like "I want to build a shopping cart" and ask for someone to give you the appropriate database design. Sure there might be some basic elements, but YOU need to determine the requiremetns which would then determine the structure needed. Quote Link to comment https://forums.phpfreaks.com/topic/268724-private-message-system-for-forum/#findComment-1380564 Share on other sites More sharing options...
Katten Posted September 26, 2012 Author Share Posted September 26, 2012 Ah yes, I wasn't asking to design one for me I was just curious as to how it works, for the sake of knowledge. Quote Link to comment https://forums.phpfreaks.com/topic/268724-private-message-system-for-forum/#findComment-1380985 Share on other sites More sharing options...
Psycho Posted September 26, 2012 Share Posted September 26, 2012 Ah yes, I wasn't asking to design one for me I was just curious as to how it works, for the sake of knowledge. I wasn't suggesting you were asking for someone to build it for you. Only that the person building such a system would have to analyze the requirements before determining the database structure. If you want to "know how it works" then I suggest finding some resources regarding database normalization. Quote Link to comment https://forums.phpfreaks.com/topic/268724-private-message-system-for-forum/#findComment-1381044 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.