Having a Super class Person which has two sub-classes Student and Staff. Student sub-class contains 3 individuals(name property): student1, student2 , student3. Staff Sub-class contains 2 individuals(name property): staff1 and staff2.
is it possible to query Person class and obtain all individuals as it is the super class?
How else can you go about this? especially when you have so many sub-classes?
Output similar to:
Person
-----------
student1
student2
student3
staff1
staff2
You need to ask for all resources that are members of either :Person
or any of its sub-classes. If you use property path, you would need only one triple pattern in your query:
SELECT ?person
WHERE { ?person a/rdfs:subClassOf* :Person}
This query asks for resources that are members of the class :Person
, which is the case when the star is zero, or are members of any of its subclasses, which is the case when the star is one and more.
If needed, you can further restrict the subject to be owl:NamedIndividual
.