How to implement a message system?
<p>I am running a website where user can send in-site message (no instantaneity required) to other user, and the receiver will get a notification about the message.</p>

<p>Now I am using a simple system to implement that, detail below.</p>

<p>Table <code>Message</code>:</p>

<ul>
<li>id</li>
<li>content</li>
<li>receiver</li>
<li>sender</li>
</ul>

<p>Table <code>User</code>:</p>

<ul>
<li>some info</li>
<li>notification</li>
<li>some info</li>
</ul>

<p>When a User A send message to User B, a record will be add to <code>Message</code> and the <code>B.notification</code> will increase by 1. When B open the message box the notification will decrease to 0.</p>

<p>It's simple but does well.</p>

<p>I wonder how you/company implement message system like that.</p>

<p>No need to care about UE(like confirm which message is read by user), just the struct implement.</p>

<p>Thank a lot :D</p>

<p>I think you will need to read about pub/sub for messaging services. For php, you can use libraries such as redis.</p>

<p>So for e.g, user1 subscribe to topic1, any user which publish to topic1, user1 will be notified, and you can implement what will happen to the user1.</p>

php python web messagebox