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;
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