Jump to content

Advice for Private Messages (trash / empty trash)


astralaaron

Recommended Posts

I am trying to figure out a way that makes sense to handle the trash bin of a private messaging system in my project.

 

When a message is sent from user_a, an entry to the 'msg_thread' table is made with the sender_id, receiver_id, subject, message, etc. I have a boolean 'trash' field for if the message is marked as trash..but if one user marks trash then it will go to the trash for both users.

 

So I am wondering, would it make sense to have sender_trash and receiver_trash instead of just 'trash'?

 

How would you handle emptying the trash bin? do you need another field for 'sender_emptied_trash' and 'receiver_emptied_trash' to know when to delete the database record?

 

Any advice?

Link to comment
Share on other sites

How do you want to do it? Sounds like you have the skill to do it any way you choose to do it. So, just do it. There's no wrong way as long as you have validation.

Link to comment
Share on other sites

What I would do is to research open source systems, or perhaps check a few different StackOverflow threads. PHPBB is open source and so is Wordpress, though I don't know if Wordpress has a PM system. There's also SImpleMachines.

 

Having two database fields for deleting is the first thing that comes to my mind, but I think there might be better ways to do it. If a PM had multiple recipients this solution wouldn't work.

 

Another solution I can think of is a new database table relating PMs with users. It probably would be best to spend time refining the idea than simply going with the first think I think of, but the table could be structured something like this:

Field PMID

Field UserID

Field Deleted ("yes" / "no")

Link to comment
Share on other sites

Having two database fields for deleting is the first thing that comes to my mind, but I think there might be better ways to do it. If a PM had multiple recipients this solution wouldn't work.

 

 

 

 

I'm glad you pointed that out, i went with setting up a separate lookup table. Thanks guys.
Edited by astralaaron
Link to comment
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
×
×
  • Create New...