Graph Database style explorations of relational database with Formula One data- Oracle Database 23c Property Graph
--
The core Formula One data could be represented in a graph like this:
Drivers compete in races that are hosted on circuits. A result is achieved by the driver (position and points for the championship).
If this is the graph, some questions can easily be answered:
With whom has a specific driver (say Max Verstappen) shared the podium?
MATCH (a IS driver where a.name = ‘Max Verstappen’) -[b IS result where b.position <= 3]-> (c IS race) <-[d is result where d.position <= 3]- (e IS driver)
WHERE NOT VERTEX_EQUAL(a,e)
Which drivers from the same country have shared the podium?
MATCH (a IS driver ) -[b IS result where b.position <= 3]-> (c IS race) <-[d is result where d.position <= 3]- (e IS driver)
WHERE NOT VERTEX_EQUAL(a,e) and a.nationality = e.nationality
Lucky day: who won two or more races on the same day in the year (different years obviously)?
MATCH (a IS driver ) -[b IS result where b.position = 1]-> (c IS race)
, (a IS driver ) -[d IS result where d.position = 1]-> (e IS race)
WHERE NOT VERTEX_EQUAL(c,e) and to_char(c.race_date,’DDMM’) = to_char(e.race_date,’DDMM’)
There are many more questions that can be answered using graph patterns in a graph pattern matching query. Patterns that are often more intuitive — easier to write, understand, debug and maintain — than their pure SQL equivalents. Of course the questions answered here can be answered using SQL as well — but these statements may not be as straightforward.
The formula one data is available to me (and you: see how in this article that allows you to fire up an Oracle Database 23c Free instance in a Gitpod workspace with a single click) in a relational database schema — 14 tables:
I have create a SQL Property Graph on top of a subset of these tables. That can be visualized like this: