In my previous post we built a graph of data from the MySQL "Sakila" database using the GraphBaseRapidGrapher tool. In this entry we'll take a quick look at the structure of the data-graph created and run some simple queries across the data.

Here's a Navigator Breadth-First-Tree-View of the Framework that RapidGrapher created from our automated Sakila database load. As you can see, the Framework is much simpler than the RDBMS Schema it's derived from.

Data is attached as vertices to the leaves of this framework as a means for describing these vertices. We can then connect these new data verices together in any way we like.

The basic operation when querying a graph is the traversal. A single directed set of traversals is the base operation in a Graph DBMS - here's the simplest way to do it do it in GraphBaseAgility Edition ...

{from {@2~1} pass [ }

This will return a Graph (Navigator view to the right) of all the vertices CONTAINED_BY the "film_rating" vertex. We could just as easily use the arc Hint (a kind of local indexing) to return the same graph. Like this...

{from {@1~1} pass H='film_rating' to { pass [ }}

This "from -> pass -> to" syntax is how we specify a traversal pattern in Bounds Language . Refer to the Bounds Language on-line help for a comprehensive description of the language.

Sure, this is a pretty trivial query - but in GraphBase you can do big things with simple queries. The great thing about structuring your data as a graph is that the complexity can stay with the data where it belongs - not in the query.

Let's look at an example from our loaded database. Everything we want to know about (say) a film "surrounds" that film in our data graph. So a relatively simple traversal pattern that reaches out a couple of "hops" can often bring us everything we need. Like this...

{ from {@2~1414 } pass [ to { pass ![ }}

This Bounds Query starts from the vertex that represents our film (dragged into BoundsPad from Navigator). It then passes all the vertices it subsumes/contains - and then from those it reaches up to get the framework vertices we've used to describe them. This is the result in Navigator...

As a programmer/developer we then, of course, need to take this result and do something useful with it. Fortunately, the result is a GraphBaseGraph and the Graph API gives us everything we need.