0

i am new to wikidata and i have tried to query query the start/ end dates of the commander of the kz dachau using sparql. I have following code but i don't get any data.

SELECT ?KZ_Dachau ?start ?end ?name
WHERE
  {?KZ_Dachau p:P1037 ?leiter.
  ?leiter ps:P1037 wd:Q151198;
          pq:P580 ?start;
          pq:P582 ?end.
   ?KZ_Dachau wdt:P1559 ?name. }

a similar query, on which my query based, works fine:

SELECT ?papst ?start ?end ?name ?pic
WHERE 
{?papst p:P39 ?position.
?position ps:P39 wd:Q19546;
pq:P580 ?start;
pq:P582 ?end.
?papst wdt:P1559 ?name.}

what i doing wrong?

I think my approach is wrong, but i don't know how to resolve it :/ And i dont understand, why i can't select any properties of the entity kz dachau (Q151198).

MySt3rY
  • 11
  • 2

1 Answers1

2

The issue is that you got the order wrong, i.e. in WikiData, the property director/manager has a person as object, not subject as in your query.

This query will work:

SELECT ?KZ_Dachau ?start ?end ?name
WHERE
  {wd:Q151198 p:P1037 ?leiter. #Notice the change in order
  ?leiter ps:P1037 ?KZ_Dachau;
          pq:P580 ?start;
          pq:P582 ?end.
   ?KZ_Dachau wdt:P1559 ?name. }

Also, you may use property paths, in this case ^ inverts the property, so that ?a :hasChild ?b will be exactly the same as ?b ^:hasChild ?a:

SELECT ?KZ_Dachau ?start ?end ?name
WHERE
  {?KZ_Dachau ^ps:P1037 ?leiter.
  ?leiter ^p:P1037 wd:Q151198;
          pq:P580 ?start;
          pq:P582 ?end.
   ?KZ_Dachau wdt:P1559 ?name. }

P39 in WikiData on the other hand has a person as a subject, hence why that query works. However, if you look at Eicke, WikiData just says that he held the position of member of the Reichstag, and says nothing about him being manager/director at Dachau.

Valerio Cocchi
  • 1,891
  • 1
  • 6
  • 18