Parameter Prefix

The SDQL provides for database joins and self-joins through parameter prefixes.

game reference

Every game is assigned two rows in the database: the home team’s side of the game followed by the away team’s side of the game. An SDQL query consists of stepping sequentially through each side in the database and taking some action. The current row of the database maps to the parameter prefix t , and contains data for the team.

To see the team and points for all NBA games played on Christmas Day 2016, use the SDQL:
t:team, t:points @ t:date=20161225

The t parameter prefix is optional and the above query is equivalent to: team, points @ date=20161225. The database row number of the current side is accessible through the SDQL variable _t.

To see the database row number, team, date, points, and site for the first 20 games in the NBA database, use the SDQL:
_t, team, date, points, site @ _t<20

Parameter prefixes provide access to data in rows relative to the team’s row. The second most common parameter prefix is o which stands for opponent’s row.

To see the team and opponent row numbers along with team names and points scored for the first 20 games in the NBA database, use the SDQL:
_t, _to, t:team, o:team, t:points, o:points @ _t<20

In parameter prefixes, the t prefix is always optional.

  • t:points is the same as points
  • to:points is the same as o:points
  • toot:points is the same as points

prefixes for all sports

The Sports Data Query Language (SDQL ©) provides reference to past and future games through parameter prefixes. Prefixes common to all sports are:

  • t for the team’s current game
  • p for the team’s previous game
  • P for the previous match up with the current opponent
  • o for the team’s opponent
  • n for the team’s next game
  • N for the next match up with the current opponent

prefixes for baseball

Because of the critical importance of pitching, the SDQL for baseball provides the additional prefixes:

  • s for the starter’s last start
  • S for the starter’s last start against the current opponent

examples

Parameter prefixes are read from left to right and can be combined without restriction.

  • tpp:site is the team’s site two games back
  • tpppo:points gives the points allowed by the team three games back
  • tPpo:points gives the points allowed by the team in the game before their previous match up.

Here are a few sample queries involving compound prefixes:

To request the season, week, team, and number of touchdowns after a team scored six or more touchdowns in each of their last two games use the SDQL:
season, week, team, touchdowns @ p:touchdowns >= 6 and pp:touchdowns >= 6
To request the date, team, points, opponent, opponent’s points, and margin for games after an NFL team wins by 40 or more points use the SDQL:
date, team, points, o:team, o:points, points-o:points @ 40 <= p:points - po:points