I have follow up question to this old answer in this https://stackoverflow.com/a/7558408/731085.
The question is about querying for all superclasses of class. Or conversely about querying for all descendant classes of superclass.
I initially thought of doing something along the lines suggested by https://stackoverflow.com/users/418267/manuel-salvadores
- Pass your RDF data through a RDF/RDFS reasoner to forward chain all entailments and assert these in your RDF database.
But here's my question: would this approach then prevent me from being able to query for all direct child classes of a given class??
I imagine the following case.
Food
Pizza
-SubClassOf Food
VeggiePizza
-SubClassOf Food
-SubClassOf Pizza
OlivePizza
-SubClassOf Food
-SubClassOf Pizza
-SubClassOf VeggiePizza
MeatPizza
-SubClassOf Food
-SubClassOf Pizza
SausagePizza
-SubClassOf Food
-SubClassOf Pizza
-SubClassOf MeatPizza
With these explicit assertions, I could get all descendant classes of Food, with something like SELECT * {?x SubClassOf <Food>}
But what if wanted to just get the direct children of Food? Is such a query no longer possible?
(P.s. I realize there are other approaches, for example, instead of explicitly stating all entailments, I could only use SubClassOf for each class's direct Parent and then query with SELECT ?subClass WHERE { ?x rdfs:subClassOf* <Food> .}
. But part of the point of my question is to understand the advantages and disadvantages of each approach. And I wanted to confirm that I've correctly understood a possible disadvantage of the above approach).