Relationships

63 views
Skip to first unread message

Michael Kreft

unread,
Jul 23, 2016, 1:33:43 PM7/23/16
to opensport
Hey Guys,

i get a example set of football.db. Aren't there any relatioships between the tables?
I can't find anything about that in the sql-dump.

Regards
Michael

Gerald Bauer

unread,
Jul 23, 2016, 1:38:23 PM7/23/16
to open...@googlegroups.com
Hello Michael,

Thanks for trying football.db.

The football.db is a relational database, thus, relationships e.g.
one-to-one, one-to-many, many-to-many are through foreign keys. You
have to use SQL to "join" tables in your query e.g.

List all world cup games [1]

SELECT t1.title,

t2.title,
g.*
FROM games g
INNER JOIN teams t1 ON t1.id = g.team1_id
INNER 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'


Cheers.

[1] http://openfootball.github.io/docs/sql-queries-intro.html
Reply all
Reply to author
Forward
0 new messages