0

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

  1. 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).

Jeff
  • 3,943
  • 8
  • 45
  • 68
  • you can use negation to check if there is not other path between superclass and subclass, so you should still be able to check for direct children – UninformedUser Apr 12 '20 at 17:48
  • Does this answer your question? [How to query for all direct subclasses in SPARQL?](https://stackoverflow.com/questions/23699246/how-to-query-for-all-direct-subclasses-in-sparql) – Stanislav Kralin Apr 12 '20 at 18:14
  • @StanislavKralin yes I think it does. With the query stated in the answer, it should be able to get back ONLY "Pizza" even though many other classes are directly asserted as a subClass of "Food", agreed? – Jeff Apr 12 '20 at 19:31

0 Answers0