Currently, I am working on a betting system for the next Fifa World Cup Russia 2018.
For this system, I have some strict points(constraints):

  • Authentication will be via external api, so no password or sensitive informations about users.
  • There are 4 types of betting: bet on a match, a bet on who will win the world cup, and a last one for the winner of each group.
  • To determine if a user won a bet, there are 3 possibilities: first one if the score he put is exactly the same, then he will win 4pts, the second one if the score is wrong, but the difference of goals is right then 3pts, the last one if one possibility from the last, then we check if he chose the right winner of the match and he gets 2pts. Otherwise, no points.
  • For matches which can contain penalties (from second roud), there is an extra betting (after typing score for the match, there is possibility to type who will win if they play 120min).
  • I want to have a statistic for the admin (games won or lost, and users bets ..etc).

As you can see in the picture below, that is what I tried out (not a complete version, i am stuck here) :
enter image description here What can be the best way to store the extra bets(as said, there are extra bets, such as the winner of this cup, the winner of each group, and the winner in the case the match goes to penalties)?

  • Please, highlight your question in the post. However, keep in mind that you should ask specific questions, not ask for an overall better solution as this can be too broad and/or primary opinion based and this might get your question closed. – Alexei Feb 14 '18 at 12:14
  • Sorry, I am stuck and I couldn't solve my problem, with having normal "bets", and the other "special bets". – Moslem Ch Feb 14 '18 at 12:16
  • You are being paid to solve a problem; why should we give you the solution for free? Here's a hint: A Database is a repository for information. An application is where the "logic" should be applied. – Rick James Feb 20 '18 at 2:00
  • I just asked about feedbacks nothing more ;) – Moslem Ch Feb 20 '18 at 19:13

I recommend that you work through the bets as follows:

First, determine what data you need to have for each type of bet. Then, look at what's common to all bets, and what only applies to some. Where possible, see if some things that appear different can be turned into something common. Last, look at where you connect to other tables, and figure out how to do that most effectively.

For example (I may get some of this wrong; not sure of how the World Cup matches all fit together):

All bets would involve:

  • a person making the bet
  • a winning team
  • a match of some sort (can you tell based on rounds, etc. what match would determine a group winner in advance, and what match will be the final match?)

Some bets involve:

  • Winning team's goals
  • Losing team's goals
  • 120 minute match or not

So I would try to build a bet table that would allow for any type of bet. If score is irrelevant for some bets, ignore it. Treat the "penalty" bets as if they are separate from the regular bets (assuming the "penalty" bet is scored independently of the regular bet's score; if there's one score, then you have to keep them together).

Since ultimately each bet will be determined by a single match (again, assuming I'm following correctly, and that winning isn't a "best two out of three" or something), I'd tie each bet to its user and to the specific match that will determine it. If the "two out of three" situation is true, try to define a "match" such that it covers either a specific game, or a series of games; or, define two different things a bet can tie to, a match or a series (or some such). If you can have "match" and "series" bets, it might make sense for them to be in separate tables (especially if all series bets have certain different options than all match bets); still, you'd want to keep the tables as similar as possible, as you're likely to want to pull some information through both tables. Do try to minimize the this sort of table split; it does complicate calculations, even if it keeps the overall DB design cleaner.

Your actual solution will be different, I'm sure, but this should help point you to the basic principles you can use.

| improve this answer | |
  • Thanks for your advice. What I thought what can be also good, to save bets with common criteria, but taking only here the person making the bet not more. Then to have a table for bet types, to determine if it was a bet on a match or a bet on winner (here only 2 cases: winner of a group and winner of world cup). – Moslem Ch Feb 15 '18 at 7:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.