Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question开发者_如何转开发I currently have designed a system for simple send message receive message using such simple table. Now I need an extra information that is which message belongs to which conversations. Any ideas tips or guidelines on implementing this kind of system?
CREATE TABLE messages (
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FromID INT NOT NULL,
ToID INT NOT NULL,
Deleted BOOLEAN DEFAULT FALSE,
SentDeleted BOOLEAN DEFAULT FALSE,
Subject varchar(255),
Message varchar(255),
DateTime DATETIME
) ENGINE=InnoDB;
just add an int column called parent_message_id and set it to the id of the message you are replying to.
The more common way, though, is to have a thread table and messages table. When a conversation is started, create a thread record and set the thread_id column of the message record to it. Set all replies' thread_id to that thread as well. That way you can SELECT * FROM messages where thread_id = x
加载中,请稍侯......
精彩评论