title: Timebased events database (approach)
body: <p>I have a general question, not about some code. So I am just asking for a general approach.</p>
  
  <p>In my game I have some time based events like in common applications as for example Clash of Clans. The user has the option to improve the skills of a character. Let's say that character "John" has an attack level of 1. To reach the next level which is 2, it needs 1 day for training.</p>
  
  <p>Now my question is, how can I achieve this. I don't want to handle this client side with a simple countdown because the risk is too high that he can manipulate the timer. I would like to store it somewhere online and the client is requesting to the server on how much time is left.</p>
  
  <p>What would be the best way? </p>
  
  <ul>
  <li>I know that there are timebased events in MySQL, so that I could simply run a task every 5 seconds but I think that this is not the best way.</li>
  </ul>
  
  <p><strong>Edit:</strong></p>
  
  <p>The problem I have is that if John starts his training, there has to be a countdown on the client side. But this countdown should not receive the remaining time clientside. The application should get the time from a server. </p>
  
  <p>With that fact it is not very difficult, because I only need to make a request to the server getting the time when the event was triggered and calculate the remaining time with the now().</p>
  
  <p>But I also want to build a live database. Where for example user "Marc" can visit the profile of John. If the time has ellapsed there should be level 2 inside the profile of John. But if John hasn't logged in there is no request to the server so that it doesn't update the level.</p>
  
  <p>So the main problem is that on the one hand I can update the database records if the user logs in by simply making a post request and updating the elapsed trainings. But if the John doesn't login and Marc wants to see his level inside his profile, then there was no post request and it is showing up level 1 instead of level 2.</p>