Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Playoff Brackets (Single Elimination Tournament)

Author  Topic 

datajive
Starting Member

1 Post

Posted - 2007-05-21 : 11:44:49
I am looking for Articles or Examples on implementing a Single Elimination Tournament architecture in SQL Server.
Bracketology, Playoff Bracket, Single Elimination Tournament, whatever you want to call it.

I need the solution to be able to support all sizes of brackets (from 8 - 64 teams and everything in between).


Any "starts in the right direction" would be much appreciated.

duncankoss
Starting Member

1 Post

Posted - 2007-06-21 : 03:54:42
I don't know if you still need help with this or not, but I am also setting up a single elimination tournament (for a golf site), and so I can explain how I chose to set it up.

I created a table to hold tournament info. The columns were:
- id (auto_increment key)
- bracketsize (int value containing the max. number of competitors... Acceptable values are 2x(2^n), i.e. 2, 4, 8, 16, 32...)
- players (number of competitors. this number must be less than or equal to the bracket size, but greater than the next bracket size down)

I created another table to hold what I called 'round' info. Quarter-finals would be a round, semi-finals would be a round... etc. I calculate the number of rounds in a tournament by running a for loop that divides the bracketsize by 2 until it obtains a value of 1. (ex: a 16 player tournament would have 4 rounds)
The fields in this table are:
- id (auto_increment key)
- matchid (the id of a match in my first table)
- round (the round number, i.e. 1, 2, 3, 4...)

My final table is called game. Each round has games, the number of which is determined by dividing either the previous number of matches or the bracket size by 2.
The table has these fields:
- id (auto_increment key)
- roundid (the id of a round in my second table)
- player1 (a player id from a table of players)
- player2 (a player id from a table of players)
- winner (contains the id of the player who wins; if the match has not happened, the value is 0)

My script calculates the number of byes by subtracting the number of players from the bracketsize, and it calculates the number of games without byes by subtracting the number of byes from the number of players, and dividing by 2. This is necessary for me, as I also have a B side to worry about.
Go to Top of Page
   

- Advertisement -