What's the database design or business logic for creating an app for messaging between users?
I am having difficulties with choosing how to approach the relationship between each Conversation of User Thread. I show this figure, but it was really hard to grasp the concept
How all this threading message works (like Gmail or Facebook)?
Best Answer
I would compose the thread of messages and then make the subsequent threads subordinate to the messages they are replies to.
For instance:
Then when you're rendering the thread, after displaying a message query for any threads who's parent message match the message you just displayed. If there are any for the message simply render that thread before going to the next message.
I've included a basic (probably technically flawed) diagram illustrating the relationships in the database.
Given the above sample it would look like this when displayed:
Update: Fixed some relationship and multiplicity issues. I updated it to include textual representations of the relationships as well. Any input on validity would be helpful, been a while since I've done one. I've been using Model Based ORM nearly exclusively lately. Also keep in mind while it use the basic format of IDEF1X. It contains specifics, and IDEF1X is a semantics based modelling system.