Jump to content

Here's one for you...


jmcall10

Recommended Posts

Hi people, :)

 

Here is one to think about, as my inferior brain cant get the maths or the query right....

 

Basically I am building a database for a five aside football match that my friends and I play each week.

 

So each week five people play five other people. However the teams are never the same and the ten people are never the same.

 

I am trying to come up with a way to log each week the results of the games and display a ladder of all the people.

 

My problem is coming up with a fair solution. You cant go on win percentage alone because if one person only ever plays one game and wins then they would have a 100% win rate. Clearly this would be wrong.

 

Any suggestions of the tables and sql involved would be much appreciated.

 

Thanks in advance

 

jmcall10

Link to comment
Share on other sites

Ah thats not so simple

 

For example, if one player plays 10 games and wins 9 and another plays 8 and wins 8.

 

The person who has played 8 and won 8 wont have as many points as the other.

 

Even tho they have won 100% of their games. Does that make sense?

 

Im trying to make the league ladder show a fair representation of how people are doing.

Link to comment
Share on other sites

So we have at least two criteria.

Total points gained and win/loss ratio (or maybe wins/total games played)

 

For starters I'd say, introduce a threshold under which players are not ranked (i.e. you have to play in at least three matches to be ranked).

This will get rid of those one-time-winners.

 

Now let's create two separate rankings. One that will rank players by their wins/games played ratio, and the other one, that will rank players by points gained

 

    Wins%        Points         Ranking points
1     a                b                     10
2     b                c                      9 
3     d                a                      8
4   ...                 ...                    ...
5
6
7
8
9
10
...

 

Now, the higher a player is in these rankings, the more 'ranking points' he/she gets. (see 'Ranking points' column above)

 

For the final ranking, a sum of Ranking points gained in both rankings is taken into account.  The higher, the better place ;)

 

 

 

That's general idea. I think it might need some tweaking and balancing, but I think it should work.

Link to comment
Share on other sites

ok i think I follow you

 

my problem is I am useless at mysql queries :(

 

My "score" table looks something like this:

 

id 	playerName 	tournamentid 	points 	dateadded
1 	Andy 		130908130403 	3 	13 September 2008
2 	Barry 		130908130403 	3 	13 September 2008
3 	Robert 		130908130403 	3 	13 September 2008
4 	David 		130908130403 	3 	13 September 2008
5 	Eddie		130908130403 	3 	13 September 2008
6 	George 		130908130403 	0 	13 September 2008
7 	Jonny 		130908130403 	0 	13 September 2008
8 	Mark 		130908130403 	0 	13 September 2008
9 	Paul 		130908130403 	0 	13 September 2008
10 	Steve 		130908130403 	0 	13 September 2008
11 	Andy 		140908120610 	3 	14 September 2008
12 	Barry 		140908120610 	3 	14 September 2008
13 	Robert 		140908120610 	3 	14 September 2008
14 	David 		140908145343 	3 	14 September 2008
15 	Eddie 		140908145343 	3 	14 September 2008
16 	George 		140908145343 	0 	14 September 2008
17 	Jonny 		140908145343 	0 	14 September 2008
18 	Mark		140908145343 	0 	14 September 2008
19 	Chris 		140908145343 	0 	14 September 2008
20 	Joe 		140908145343 	0 	14 September 2008

 

So how do I code/query that? :(

Link to comment
Share on other sites

You at least need one more column for 'games played'

 

 

That's how I would plan database for such an  app

 

table players (holds data about players)
playerID, firstName, lastName, gamesPlayed, gamesWon, points
1,Andy,Foo,2,2,6
2,Barry,Bar,2,2,6
3,Robert,Baz,2,2,6
4,George,Was,2,0,2
...


table matches (holds data about matches)
matchID, datePlayed, teamAscore, teamBscore
1,13-09-2008,3,1
2,14-09-2008,1,2
...

table matches_players (assigns players to matches and teams, you can also keep some stats here like number of goals a player has scored in a match)
playerID, matchID, team
1,1,A
1,2,B
2,1,A
2,2,B
3,1,A
3,2,B
4,1,B
4,2,A
...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.