Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database modeling for defining and processing realtime sports events

I am trying to store and process sports events in realtime and want to create an optimal system as this will process 100s of events per second. The system will store the events before a sports match and then process them in real-time or at end of a half/session/match.

In my system, every Event is broken down into following components

  • WHO whom is the event related to. A team, player, refree, spectators, etc
  • WHAT what is the event (goal, pass, save, etc)
  • WHEN time details of the event
  • HOWMUCH how is the event value defined
  • TYPE defines when should it be checked - INDIVIDUAL : realtime, AGGREGATE : end of WHEN

Here are some examples for soccer

1. No goals scored in 2nd Half
TEAM: *, WHAT: __GOAL, WHEN: __HALF_2, HOWMUCH: 0, TYPE: AGGREGATE 
{
    "who" : {"team":*},     
    "what" : "__GOAL",
    "when" : "__HALF_2"
    "howMuch" : {"value":0, "type" :"exact"},
    "type" : "AGGREGATE"
}


2. Either keeper to complete 3 or more punches
PLAYER: (p1 v p2), WHAT: __PUNCH, WHEN: __MATCH, HOWMUCH: 3+, TYPE: INDIVIDUAL
{
    "who" : {"player":{"or":["p1","p2"]}},  
    "what" : "__PUNCH",
    "when" : "__MATCH"
    "howMuch" : {"value":2, "type":"more"},
    "type" : "AGGREGATE"
}

3. Coutinho to score a goal before 65th min
PLAYER: p3, WHAT: __GOAL, WHEN: <65, TYPE: INDIVIDUAL
{
    "who" : {"player":"p3"},    
    "what" : "__GOAL",
    "when" : {"value" : 65, "type" : "before"}
    "type" : "INDIVIDUAL"
}


4. Henderson to play highest number of passes
PLAYER : p4, WHAT: __PASS, WHEN: __MATCH, HOWMUCH: __MAX, TYPE: AGGREGATE
{
    "who" : {"player":"p4"},    
    "what" : "__PASS",
    "when" : "__MATCH",
    "howMuch": "__MAX"    // this is a key word which will be handled accordingly on the application
    "type" : "AGGREGATE"
}

5. Liverpool to have more possession than everton
TEAM: (t1 > t2), WHAT: __POSSESSION, WHEN: __MATCH, TYPE: AGGREGATE      
{
    "who" : {"team":{"compare":["t1","t2"],"winner":"t2"}},     
    "what" : "__POSSESSION",
    "when" : "__MATCH"
    "type" : "AGGREGATE"
}

All AGGREGATE events will be checked when the state of the match changes. e.g. IInd half ---> MATCH_END

All INDIVIDUAL events will be checked for in real-time (as soon as a new event is received). This works on web hook.

E.g. A goal is scored in the 58th minute. Event received by system - {"type":"goal","player":"_henderson_", "minute":58}

The system would now run a "find" where ("type" == "INDIVIDUAL" && "what" == "__GOAL") and compare all the events found.

Later on, I would like to provide an admin functionality for writing sentences which can be parsed into this structure. What I want to know is if I am working in the right direction or do I need to start thinking in a different way.

like image 329
Akshat Goel Avatar asked Dec 21 '16 17:12

Akshat Goel


People also ask

How are databases used in sports?

Databases can be used to store all different data types including continuous or categorical data. As related to sport performance, this data can include performance data from competitions or any other type of data that a coach collects during the pre-season, competitions, or post season.

Which tool can be used to analyze sports data in real time?

Sports performance analytics software can be customized to track key metrics for any given sport, such as total basketball shots or total football interceptions, and can monitor individual athlete statistics and game performance over time.

What is the importance of data and database sports and entertainment?

Data is an important part of the sports industry for players, coaches, management, sports medicine workers and fans. Not only can data analytics help teams win games, these statistics can also help improve player performance, prevent injuries and encourage fans to attend games.

What are the applications of big data in sports?

Big data is helping us create better sporting strategies Data science allows coaches of professional teams, in particular, to create hyper-personalised athlete matchups and other strategies for every match the team plays. This way the team's tactics are left unpredictable yet effective.


1 Answers

Your choices are probably between Spark and Dataflow. Here's a nice white paper comparing the two that actually uses a similar use case to yours (large scale mobile game user scoring in real time). Good luck, seems like a cool project (looks like an online bookmaking implementation?).

like image 199
Dominic Tracey Avatar answered Sep 17 '22 12:09

Dominic Tracey