Named Graph

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

In SPARQL one can selected Graph Patterns from more than one Graph. Therefore one need to distinguish in SPARQL the first (the default) Graphs that all formulated Patterns will be asked for and one can in the same SPARQL Query refer to other Graphs. These other Graphs (zero or more) are so called RDF named Graphs. So one has named Graphs that can be explicitly addressed within a Query and one has default Graphs that will be addressed whenever no named Graph is addressed in that way. For this one has the Graph keyword.

Assuming one has several from Statements, the normal FROM Statements form the default Graph. Each specified Graph Pattern that is not bound to a specific Pattern belongs to the default Graph and the Query will be carried out against the default Graph. Named Graphs are indicated with the FROM NAMED followed by the Graph URI. The same Graphs can be in the Default Graph as well as in special Named Graphs for the specific parts that occur in the WHERE Clause. Everything in the WHERE Clause where there is not a specific Graph Pattern is specified will be checked against the Default Graph. Everything that is specified via the GRAPH keyword will queried against the defined Named Graph.

For instance in a default graph with two triples of individuals that are characterized by two files that are two URIs. The URIs stands for Named Graphs. In the example the query selects a Graph, a mail box and who belongs to the mailbox. In the WHERE Clause it asks for the graph ad the name of the publisher. Then the GRAPH keyword specifies that the next Graph referring to where x is the mail box and mbox the name of the mailbox. Therefore, a Named Graph can also be a Variable will be computed from the evaluation of the Triples before from the default Graph. Then in the execution the Variable will be substituted by a value that has been computed when evaluated the Graph Triple Pattern from the default Graph.


Tags: query, programming, namespace, selection, coding, graph
Categories: Tutorial
Parent: SPARQL

Update entry (Admin) | See changes

Comment on This Data Unit