开发者

Implementing a conversation style private messaging system [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜