Friday, 23 August 2013

Proper way to create ranking table?

Proper way to create ranking table?

I am creating tennis site which of course needs to display results.
Currently to get ranking I need to sum scores for each player and then
order them, even if I only need single player results. I think that it
will be really slow when player count in system will rise. That's why I
need some way to cache results and update them only when something
changed(or add some sort of timeout when results has to updated).
Also other requirement would be being able to calculate total scores i.e.
I will have several competitions and I will need to show scores for all
competitions, and for each competition separately.
What I currently thought of would be single table to store everything.
It's schema would be:
ranking_tbl shema
rank_type(could be competition, team, player or something else)
rank_owner(who owns those ranks, can be team player ranks - owner would be
team)
rank_item(who is ranked, in team example would be player )
score(actual score to rank by)
rank(precached rank, updated only when new scores added)
Ranking will be important part of my system and used heavily so I need it
to be as efficient as possible.
Question: Is there better way to achieve ranking than using my table shema?

No comments:

Post a Comment