What does ';' operator in WHERE clause means in SPARQL?
For example:
SELECT ?x ?y WHERE { ?z foaf:name ?x ; :surname ?y }
What the ; operator means here? Is like a logical and that means this part
?z foaf:
goes before :surname again?
SPARQL can be used to express queries across diverse data sources, whether the data is stored natively as RDF or viewed as RDF via middleware. SPARQL contains capabilities for querying required and optional graph patterns along with their conjunctions and disjunctions.
It's a SPARQL 1.1 property path which describes a route through a graph between two graph nodes, in your case it denotes the inverse path, i.e. from object to subject, thus, it's equivalent to. dbpedia:Stephen_King a ? subtype .
What is a SPARQL Query Service? A SPARQL Query Service is an HTTP Service (also known as a Web Service) that offers an API for performing declarative Data Definition and Data Manipulation operations on data represented as RDF sentence collections.
SPARQL (pronounced "sparkle" /ˈspɑːkəl/, a recursive acronym for SPARQL Protocol and RDF Query Language) is an RDF query language—that is, a semantic query language for databases—able to retrieve and manipulate data stored in Resource Description Framework (RDF) format.
It's not a SPARQL operator, but rather part of the syntax for triple patterns in SPARQL. The full specification is in section 4.2 Syntax for Triples from the SPARQL spec. Subsection 4.2.1 Predicate-Object Lists describes the ;
notation:
Triple patterns with a common subject can be written so that the subject is only written once and is used for more than one triple pattern by employing the ";" notation.
?x foaf:name ?name ; foaf:mbox ?mbox .
This is the same as writing the triple patterns:
?x foaf:name ?name . ?x foaf:mbox ?mbox .
You might also be interested in subsection 4.2.2 Object Lists:
If triple patterns share both subject and predicate, the objects may be separated by ",".
?x foaf:nick "Alice" , "Alice_" .
is the same as writing the triple patterns:
?x foaf:nick "Alice" . ?x foaf:nick "Alice_" .
Object lists can be combined with predicate-object lists:
?x foaf:name ?name ; foaf:nick "Alice" , "Alice_" .
is equivalent to:
?x foaf:name ?name . ?x foaf:nick "Alice" . ?x foaf:nick "Alice_" .
The same syntax is used in Turtle and N3 serializations of RDF. See 2.3 Abbreviating groups of triples for Turtle, which says
The , symbol may be used to repeat the subject and predicate of triples that only differ in the object RDF term. … The ; symbol may be used to repeat the subject of of triples that vary only in predicate and object RDF terms.
and for N3, see the Semantics section, which says:
In property lists, the semicolon ; is shorthand for repeating the subject. In object lists , is shorthand for repeating the verb.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With