[eluser]obiron2[/eluser]
Hi guys,
I wanted to guage opinion on how you would store the following information in a database.
I am building a league system where n players will play against each other in a season.
There is no Home/Away denomination so A vs B is the same game as B vs A.
I will need to add up all the points each player has scored and show them in a grid against the players they played, with the highest scoring player first.
E.g. 5 players A-E should produce a grid like this:
Code:
. A B C D E
A X 5 5 4 5
B 2 X 5 5 5
C 3 2 X 4 5
D 5 1 5 X 2
E 1 0 1 5 X
I will need to find all the results for player A and all the results against player A
I will need to sum the results for each player and order them by sum
I am thinking a table with GameID, PlayerID and PlayerScore but how would you go about populating it to ensure that each player ID is populated into 4 games and each game has 2 players (i.e. that all the valid combinations are covered) I would prefer to be able to do this as a bulk insert rather than active record as there could be a lot of them.
The other alternative is a game record with player1 and player2, but this could lead to a number of indexing issues.
Advice please
Obiron