title: Viewing a "log" of new (distinct) events in a database
body: <p>I have an application which has several unrelated tables in its db. I'll explain by using an "auto-updating" version of the SO homepage as an example, so lets say I have the tables "<strong>users</strong>", "<strong>comments</strong>" and "<strong>questions</strong>".</p>
  
  <p>The homepage client side needs to periodically poll the server, and get a log of all the new "events" that have happened. I.e., I'd like to display (somehow) the new questions, comments and users that have been added to SO since the last poll.</p>
  
  <p>On way would be to simply keep a variable on the client side containing the last index of each of my tables, send it to the server, and have the server send me the new users, comments and questions.</p>
  
  <p><strong>The problem is,</strong> what happens when I add a new type of information, say, votes. Now I have to store another variable on the client-side, and the server has to poll another table. And so on, for every new type of information I keep.</p>
  
  <p>I'm looking for a solution that helps me avoid this.</p>
  
  <p>Another problem - say I'd like to see all the "events" that have happened since last time, but sorted according to when they took place.</p>
  
  <p>One direction I had is to have a single "events" table, which contains the info about when each event happened. I can then poll only this table, and get a list of all the new events that have happened. The problem is that each event is pretty different (a new comment has different columns than a new upvote, etc.) So I'm not sure how to implement this, or if this is even a good idea.</p>
  
  <p>Does anybody have any ideas how I can solve this? This seems like something that would come up a lot, but I don't really have much experience with databases, unfortunately.</p>
  
  <p>Thanks!</p>