I’m trying to write a query that retrieves all the species of flowers in Wikidata.
As far as I understood, flowers are represented by class Q506: https://www.wikidata.org/wiki/Q506. Therefore I tried to retrieve all the instances of this class. I used this query:
SELECT DISTINCT ?flower ?flowerLabel
WHERE
{
?flower wdt:P31 wd:Q506 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
However this query returns only 19 objects. This number is nowhere near the number of flowers I expected.
Then I tried searching for the subclasses of class Q506. I used this query:
SELECT DISTINCT ?flower ?flowerLabel
WHERE {
?flower wdt:P279 wd:Q506.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
I got only 26 results. And again this is not what I expected.
I also tried some other approaches. For example I tried to start from the class of Angiosperms (Q25314) and go back to the species of flowers using a series of parent taxon properties (P171). However I didn’t get all the results I needed since some popular flowers were still missing.
I’m sure there is a way to get the information I need since there are WikiMedia pages that contain exactly what I want. For example there is this Category page of flowers: https://commons.wikimedia.org/wiki/Category:Flowers. And there is also a page with Commons media, which is what I ultimately want to reproduce: https://commons.wikimedia.org/wiki/Flowers.
I’m trying to write the query for Wikidata, but for me it would be fine to use other databases, like DBpedia for example.