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.
So far everything works fine. Now I am thinking to add an ELO rating system.
I can not understand, how should I design my database.
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.
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?
an illustrative example of my problem, i can not solve (rating calculation just informative):
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
So, then I realize, that game 2 has false data, I want to delete it.
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
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.
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.
I hope my problem is clear...
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.
Thanks in advance.