More Features for Simple Messaging System

We have covered a lot with our simple messaging system. But, there are always more features we can add. Here are some I can think of :

Message Editing

Now, normally once a message is sent, there is no way to edit it. But, suppose we allow it to happen. What possible problems can happen and how do we handle it ?

The primary problem is with timestamp. Because it will affect how we sort the message replies. If we depend on the timestamp, the messages order will be in chaos.

Immediately we split and create two timestamp, one for creation and the other for editing. This solves the sort problem, because we simply sort by creation timestamp. But for editing timestamp, what happens if the user updates it more than one time ?

Now, in finding a solution, I can say the solution also solves the problem if we want to keep the editing history intact. So, we can tell what changes in the message with each edit.

The solution is to create a new table called message_history. Then for each edit, we update the original message record and push the old record into message_history.

We add a new message_history_id and change the message_id to message_id_original in table message history.

Mark Message As Read / Unread

Another feature we can add is to mark the message as read  /unread. This is actually an email kind of thing. If you noticed Facebook and Twitter, they do not use this feature. They allow the message to be marked as Liked in Facebook and Favorite in Twitter.

This can be done by simply creating a field called message_read in table message. We use simple boolean value, TRUE for read and FALSE for unread with the default value of FALSE.

A problem can occur with announcement. It is a single message send to a lot of people. So, the field definitely cannot handle the situation. In this case, we simply marked it as always TRUE. We assume people have read it.

Or, we can create a new table called message_read, where we put :

  • message_read_id <- auto increment table id
  • message_id <- the message id
  • user_id <- the user id who have read the message

Whenever a people read the announcement, we insert into the table, the user_id and the message_id.

That is all the new features I can think of. You have any other idea for features that will improve our simple messaging system ? Please share in the comments below.