Private Message module

Hello guys,

I am kinda stuck. Please help.

I am writing a PM system.

  1. User can send a message to multiple users
  2. Inbox/Sent box Folders

Below is the schema to handle just that, but the problem is when some reply to the message Its coming in my inbox thats fine but I can’t seems to figure out is_read feature. Can you please suggest?


CREATE TABLE `private_messages` (
  `msg_id` int(20) NOT NULL auto_increment,
  `last_response_id` int(20) NOT NULL,
  `fromuserID` int(20) NOT NULL,
  `subject` varchar(200) NOT NULL,
  `body` text NOT NULL,
  `msg_date` datetime NOT NULL,
  `is_delete` tinyint(1) NOT NULL,
  PRIMARY KEY  (`msg_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

-- 
-- Table structure for table `private_message_recipients`
-- 

CREATE TABLE `private_message_recipients` (
  `id` int(20) NOT NULL auto_increment,
  `msg_id` int(20) NOT NULL,
  `fromuserID` int(11) NOT NULL,
  `touserID` int(20) NOT NULL,
  `folderID` smallint(1) NOT NULL,
  `is_read` tinyint(1) NOT NULL,
  `is_new` tinyint(1) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

-- 
-- Table structure for table `private_message_responses`
-- 

CREATE TABLE `private_message_responses` (
  `response_id` int(20) NOT NULL auto_increment,
  `msg_id` int(20) NOT NULL,
  `response` text NOT NULL,
  `posterID` int(20) NOT NULL,
  `response_date` datetime NOT NULL,
  PRIMARY KEY  (`response_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

Thanks in advance

trying to mimic Facebook MEssages.

private_messages: One user can send a message to multiple and this message.
private_message_recipients: Only those who are involved in this message thread
can view/reply to it. -

private_message_responses: Responses to a message.

I know there’s something missing with respect to database structure. Can anyone please help me in resolving this issue?

ive worked on somthing like this b4

i would recommend having a field in the database getting updated every if the message has been read yet so somthing like this s=“SELECT * from pms where user=‘watever’ and readyet=‘1’”; that is 1 way i did mine not sure if that would help.