I made a derivation of the cats with images example where I query for a specific cat, in particular its label and a possible image (in the web interface):
SELECT ?item ?itemLabel ?pic
WHERE {
FILTER ( ?item = wd:Q17000472 ) .
OPTIONAL { ?item wdt:P18 ?pic . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
I do not care whether it's a cat as I just want to query basic info of any entity. Including such constraint (?item wdt:P31 wd:Q146 .
) would actually give a result, but again the entity could just be anything.
Am I deducing correctly that a WHERE
statement in SPARQL
expects at least one 'unoptional' triple? What would be a good pattern to query optional properties of a specific entity without any knowledge about it?