3

In the Wikidata SPARQL samples, I found this query:

What is the relation between Terrell Buckley and Miami Dolphins? Items used: Terrell Buckley (Q5571382), Miami Dolphins (Q223243)

SELECT ?l 
WHERE
{
    wd:Q5571382 ?p wd:Q223243 .
    ?property ?ref ?p .
    ?property a wikibase:Property .
    ?property rdfs:label ?l FILTER (lang(?l) = "en")
}
LIMIT 10

Try it

I found really hard to know why you can't simply write:

SELECT ?l 
WHERE
{
    wd:Q5571382 ?property wd:Q223243 .
    ?property a wikibase:Property .
    ?property rdfs:label ?l FILTER (lang(?l) = "en")
}
LIMIT 10

Removing the ?p intermediate variable.

The fact it doesn't work numbs me beyond comprehension, I don't know if I'm simply too stupid to understand it, but, could you help me, guys?

  • BTW, I think for questions about SPARQ, you have a better chance of getting an answer at Stack Overflow. – svick Mar 20 '16 at 15:07
  • Thanks @svick , I'll take that into account, but, I think it's not about the language (both ways are perfectly valid SPARQL), but the content of wikidata graphs. – David Sánchez Martín Mar 20 '16 at 19:24
5

In the original query ?property and ?p are distinct values: ?property is wd:P54 (short for <http://www.wikidata.org/entity/P54>) and ?p is wdt:P54 (short for <http://www.wikidata.org/prop/direct/P54>). Notice that both refer to P54, but they are not the same. The two are connected by ?ref, which is wikibase:directClaim.

This is why your simplified query doesn't work.

  • Yep, I already found that, the wdt vs wd issue but, the question is, why in the world they decided to separate the Properties metadata into another namespace?. I don't see the advantages of such approach. Have you any clues? – David Sánchez Martín Mar 20 '16 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.