Mentions on a page how to handle

A user can mention another user on my page.. That is he just writes something like hello @rohit.
So i need to save this comment in Database. If i save the exact comment "hello @rohit" the problem is that if the user changes its display name from rohit to rohit1 This wont get reflected on the page..
So i need to store hello someId  which corresponds to the user.. And while returning the response i need to replace the id's with the name.
Please suggest exact ways how i can accomplish this... As obviously in the above the user may actually type in hello someId and so there should not be any parsing.
I have one approach but dont know if its effecient or work well..
a cooment like hello @rohit  will go in the db like hello <user>id</user>
Basically we will use a xml tag . And also convert the rest of the string which is hello here... may be encode it so that it doesnt mix with xml...And then while returning the response we just parse the user tag and replace every id with name.

Please suggest pros and cons of the above. And any alternative ways.
Rohit BajajAsked:
Who is Participating?
Ryan ChongCommented:
it would be a bit risky if @rohit is a representation of user's display name instead of user's id. just imagine the situation where there are multiple users with same display name, which user id will be mapped?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.