football.db SQL Queries Made Easy (Thanks to Views)
Oct 21, 2014
First thanks to Joe Kampschmidt for getting started w/ some SQL queries examples.
Added some SQL views to make it easier to query the football.db
.
Example - List World Cup Brazil 2014 Games:
Before (Table Edition):
SELECT t1.title,
t2.title,
g.*
FROM games g
LEFT OUTER JOIN teams t1 ON t1.id = g.team1_id
LEFT OUTER JOIN teams t2 ON t2.id = g.team2_id
INNER JOIN rounds r ON r.id = g.round_id
INNER JOIN events e ON e.id = r.event_id
WHERE e.key = 'world.2014'
After (View Edition):
SELECT *
FROM events_games_list
WHERE e.key = 'world.2014';
More views include:
teams_list
games_list
events_list
events_teams_list
events_games_list
events_rounds_list
events_groups_list