Yeah message tables could be quite tricky. Heres the SQL that I use
for my messaging system.

user_id = User who sent the message
recipient_id = Use who receives it, of course

CREATE TABLE IF NOT EXISTS `messages` (
  `id` int(11) NOT NULL auto_increment,
  `user_id` int(10) unsigned NOT NULL default '0',
  `userFolder` enum('inbox','sent','saved','trash','deleted') NOT NULL
default 'inbox',
  `recipient_id` int(10) unsigned NOT NULL default '0',
  `recipientFolder` enum('inbox','sent','saved','trash','deleted') NOT
NULL default 'inbox',
  `status` enum('read','unread','replied','forwarded') NOT NULL
default 'unread',
  `subject` varchar(35) NOT NULL,
  `content` text NOT NULL,
  `created` datetime default NULL,
  `modified` datetime default NULL,
  PRIMARY KEY  (`id`),
  KEY `user_id` (`user_id`),
  KEY `recipient_id` (`recipient_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Internal messages for
user to user' AUTO_INCREMENT=1 ;
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to