How should I find the correct property for a query?
Say I want to find all the kings in wikidata.
My first attempt was this:
SELECT ?king ?kingLabel
WHERE
{
#all result where occupation is king
?king wdt:P106 wd:Q12097.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
It returned total 515 hit. Which I think is very small number for all the kings.
Second attempt:
SELECT ?king ?kingLabel
WHERE
{
# all result where position held is king
?king wdt:P39 wd:Q12097.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Which returned 817 hits.
So you can see I used different properties: P106
vs P39
. They returned different result set. And those are only two properties, maybe it exist another 10-12 properties which I haven't discovered yet and would be better for my query.
edit: And on the top of that the usage of given property doesn't seem to be consequent. For property of P39
(position held) some wiki pages has the value of Q12097
(king) others has Q6412254
(king of Hungary).
So as you can see it is impossible to fetch all the kings in wikidata with one query. Or should I fetch bunch of properties and parse their values for the word king? It would be a nightmare but right now couldn't find a better way.
Right now the usage of properties seems ad hoc to me unfortunately and because of this I am using a trial and error method for discovering properties .
So my question is (and it isn't related to the 'king' problem only):
If I want to formulate a query how can I decide which is the best property?