|What is my age:||I am 44|
Stack Overflow to learn, share knowledge, and build your career. Connect and share knowledge within a single location that is structured and drama chat to search.
Chat data model ( database diagram)
I am working on implementing chat functionality in Spring-MVC. This is meant for private chat only.
Now there is a situation where I have 2 users who are chatting. I would like to store their chats in the database. I am trying to think how can I save it so I can search for conversations between two users in a efficient manner.
Cultural-historical activity theory
Each message has a messageid, messageTimeStamp, messageText and an identifier. Now this identifier is a String value of user1:user2.
So when I want to load a conversation between two users, I have a logged in user1, so I can search in database where identifier user1 is present and load them as history. Problem is loading individual chat history and overhead.
Does this approach model good, any suggestions are welcome. Thank you. I think no registration sex chat in baltichioni idea is not that bad male for female chat start, but using an identifier column where you merge chat users in a string value 'user1:user2' is not really efficient.
You will have to operate with strings later on and you cannot index the sender and the receiver of the message separately. You could rather store the user id of the sender and the receiver in separate columns. One other thing that you might consider is to have a separate 'conversation' or 'chat' table to store conversation relation data between users.
Then, you refer to a conversation from the message table. So your tables might chat like:.
One benefit is that, when you just want to operate with the conversations, e. You can find some more examples with a detailed explanation of such a de here.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Adult free phone chat more. Chat database model Ask Question. Asked 6 years, 3 months ago.
Active 6 years, 3 months ago. Viewed 5k times. Currently my idea is : Each message has a messageid, messageTimeStamp, messageText and an identifier.
Improve this question. We are Borg We are Borg 4, 13 13 gold badges 79 79 silver badges bronze badges. Add a comment.
Active Oldest Votes. Improve this answer.
Turns out, I implemented what you said already. Thanks for the info though.
Subscribe to rss
You are welcome, good to see that you ended up with the same solution. up or log in up using Google. up using Facebook.
up using and Password. Post as a guest Name.
Applying schema resonance model in live chat e-service
Required, but never shown. The Overflow Blog. Podcast A curious journey from personal trainer to frontend mentor.
Find knowledge faster: New Articles features. Featured on Meta.
New onboarding for review queues. Related Hot Network Questions. Question feed. Accept all cookies Customize settings.