title: ELO rating - mysql design
body: <p>I am a complete new starter in programming.
  I just made a system for personal use.
  There is a possibility to add sports match results of two players.</p>
  
  <p>So far everything works fine.
  Now I am thinking to add an ELO rating system.</p>
  
  <p>I can not understand, how should I design my database.</p>
  
  <p>Problem is, that I can not understand, how to keep correct record of rating calculation in case if any game result will be deleted at any time. For example, somebody will add faulty data and game entry should be deleted.</p>
  
  <p>So, how should the database design be made, that if I will delete any game from the middle of entries, the rating will recalculate correctly?</p>
  
  <p>an illustrative example of my problem, i can not solve (rating calculation just informative):</p>
  
  <pre><code> Player1 (rating 1200), Player2 (1200)
   Game1 played, player1 wins.
   Rating after game: P1:1231, P2:1169
   Game2 played, Player1 wins.
   Rating: P1:1259, P2:1141
   Game3, Player2 wins
   Rating: P1:1220, P2:1180
  </code></pre>
  
  <p>So, then I realize, that game 2 has false data, I want to delete it.</p>
  
  <p>What should happen?
  I delete game2, then the script should alter the rating like
  Grab rating of both players from one game before, from after game1. which would be P1:1231, P2: 1169
  And then recalculate all rating after the deleted game.
  So Game3, player wins, rating should be P1:1198, P2:1202</p>
  
  <p>I can not just delete game2 and it's rating differences... rating has to be recalculated from the previous game and for all after games played.</p>
  
  <p>More complicated it gets if there are 3 or more players, and they have played games after the one I want to delete.
  Because of their ratings have changed. And if a game is deleted, then all rating changes of games played after should have be recalculated one by one.</p>
  
  <p>I hope my problem is clear...</p>
  
  <p>So thew question is, could you please give me, a complete starter of php/.mysql a hints of what should be the logic of database and process of calculating the ratings for my situation.</p>
  
  <p>Thanks in advance.</p>