11

In one of the samples for querying Wikidata, I found the following query, which includes p:P6/v:P6 in the line after SELECT. What does it mean?

PREFIX wd: <http://www.wikidata.org/entity/> 
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>

SELECT ?p ?w ?l ?wl WHERE {
   wd:Q30 p:P6/v:P6 ?p .       #-- This line
   ?p wdt:P26 ?w .
   OPTIONAL  {  
     ?p rdfs:label ?l filter (lang(?l) = "en") . 
   }
   OPTIONAL {
     ?w rdfs:label ?wl filter (lang(?wl) = "en"). 
   }
 }
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
  • Note that you should generally use **langMatches** to compare language tags, not `=`. E.g., **langMatches(lang(?x), "en")**. – Joshua Taylor Feb 28 '17 at 15:48

1 Answers1

21

It's the SequencePath flavour of a SPARQL 1.1 property path.

wd:Q30 p:P6/v:P6 ?p .

means that there is a triple (wd:Q30, p:P6, ?x), and another triple (?x, v:P6, ?p), without an explicit need to write (or name) the intermediate node ?x. In other words, it says: "?p can be found by starting at wd:Q30, following property p:P6, and then property v:P6.

O. R. Mapper
  • 20,083
  • 9
  • 69
  • 114