Previous topic  Top  Next topic  Print this Topic
 

Graph Queries

 

The resulting graph of CONSTRUCT and DESCRIBE queries is represented as a set of triples. Each triple maps to one solution, providing a triple instantiation: Variable $s for subject, variable $p for predicate, and variable $o for object position.

Example: Given the RDF ontology

@prefix : <http://www.example.com/ontology#> .

@prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#> .

 :alice :name "Alice" .

 :bob :name "Bob" .

and the SPARQL query

PREFIX : <http://www.example.com/ontology#>

PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>

CONSTRUCT { ?person vcard:FN ?name }

WHERE { ?person :name ?name }

will produce the resulting graph, represented as triples via variable bindings

$s

$p

$o

 :alice

vcard:FN

"Alice"

 :bob

vcard:FN

"Bob"

which equals the RDF ontology

@prefix : <http://www.example.com/ontology#> .

@prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#> .

 :alice vcard:FN "Alice" .

 :bob vcard:FN "Bob" .