title: Java Group Chat Application: Knowing if groups have users currently active
body: <p>For the past 2 weeks, I have been working on a java group chat application. So far a user can login and join groups created by other users. The user can also send chat messages to each other inside of each group. The message distribution is handled by a server and the server only sends the chat messages to clients of the group from which it was sent. A list of groups which the user is a part of is also displayed, and I would like for there to be a small green mark(or anything else to notify the user) to let the user know if there are other users currently active on that chat room group. </p>
  
  <p>Here is how my groups are stored in the database</p>
  
  <pre><code>**TABLE groups**
  
   - id
   - user_count
  
  **TABLE group_members**
  
   - groupid
   - userid
  </code></pre>
  
  <p>The sending and receiving of chat messages are handled using sockets, and none of the sent messages are stored on the database. I was thinking of maybe having a field in the groups table where every time a user joins would increment the value in it by 1 and every time a user leaves, the value goes down by 1. This way if the number stored in this field is 0, there are no current users on here. I think there may be a better way to handle this though.</p>