Graph Pattern

Created on Feb. 23, 2013, 9:20 a.m. by Hevok & updated by Hevok on May 2, 2013, 5:18 p.m.

A Graph Pattern defines how a RDF Graph accessed and transversed is inside the SPARQL Endpoint.

The Graph comes with a Triple Pattern. Triple Pattern means one has Triples inside RDF, all organized as Subject, Property and Object. A Triple Pattern consists out of Turtle Triples and Variables. For example if one is looking for Countries and their Capitals and one is aware of that inside the Knowledge Base there is some Triples where some Capitals for Countries are given (which comes from the Vocabulary with the Prefix geo, one might construct a Graph Pattern where one has the Country as a Subject Variable. Then one says after this Property there comes the Property geo:capital which is fixed as it is the URI of a specific Property. Then one has the second Pattern which is a Variable Capital. And then the RDF Graph is transversed and all Triples that confirm to this Pattern, for example, one will find Triples of the Graph that is queried. Among them are Triples that have the geo:capital and the Subject is selected as Country and the Object is selected as Capital. All those fulfilling this Query will be returned as the answer of this RDF Query Statement. So it is simple as one has a Graph Transversal that looks for Patterns where one has Variables and some URIs or Literals that are fixed and that can be mapped to Triples inside the RDF Graph.

If one is looking for someones Name, i.e. find a given Person and for this Person the FOAF URI. foaf is a Vocabulary that is Friend of a Friend where one can encode and describe Knowledge about Persons and the Social Network Information of a Person. One of the Properties their is the foaf:name. Given a URI with a foaf Description of a person one can look for a Graph Pattern that states that the Subject must be the Person, the Property must be the Name and then one is looking for the Variable ?surename to look for a Name of Person.

If one asks for which Persons, i.e. Subjects, have a certain Family Name, so one has the Variable one is selecting, the first one is Person, then one has a fixed Property, namely the Family Name and one has a fixed Literal with this one says the Value of this Property must match, please give all the Subject that refer to that, i.e. select all the Triples that confirm to the Triple of this Graph Pattern.


Tags: query, match, graph, database
Categories: Tutorial
Parent: SPARQL
Children: Complex Query Pattern

Update entry (Admin) | See changes

Comment on This Data Unit