I'm building a gambling-related website where people can be on soccer fixtures (matches). A fixture ends up with a result: home win - draw - away win. I have one table for teams and one table for fixtures and another for bets. The fixtures table has a home team and an away team. But how do I model a draw bet? It's easy to have the bet table refer to the fixture and refer to the team. But a draw?
-
The bet doesn't refer to a team; the bet refers to the outcome of a fixture. You don't record the team that will win; you record the outcome of the match. Don't forget you'll need customers and that it is customers who place bets.Jonathan Leffler– Jonathan Leffler2009-09-08 13:56:28 +00:00Commented Sep 8, 2009 at 13:56
-
Also, in the classic (UK) pools, there is a distinction between a score-draw (eg 1-1) and a no-score-draw (ie 0-0). Just an FYI.Jonathan Leffler– Jonathan Leffler2009-09-08 13:57:26 +00:00Commented Sep 8, 2009 at 13:57
Add a comment
|
1 Answer
The most basic system:
3 tables, one for teams, one for fixtures and one for bets. Outcomes are represented by:
0 => Draw, 1 => Home win, 2 => Away win
Teams:
id | name
-----------------
1 | Some team
2 | Some team
3 | Some team
Fixtures:
id | home team | away team | result
--------------------------------------
1 | 1 | 3 | 0
2 | 2 | 3 | 2
3 | 1 | 3 | 1
Bets:
id | fixture | outcome
---------------------------
1 | 1 | 0
2 | 2 | 1
3 | 1 | 3