Reputation: 838
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?
Upvotes: 1
Views: 1625
Reputation: 2415
I think your schema will work. I can see 3 possible solutions that you could use to get your desired functionality.
I would personally prefer the 3rd option but it may have a little more overhead in time consuption to initially set up.
Hope this helps.
Upvotes: 1