66 
 
Chapter 9 Queries: Description Logic and SPARQL 
Now that we have some individuals in our ontology, we can do some interesting queries. There are 
several tools for doing queries in Protégé.  
9.1 Description Logic Queries 
To start with the most straight forward one based on what you have already learned are Description Logic 
(DL) queries. These are essentially the same kind of statements you have been using to define classes. 
However, in addition to using such statements to define a class you can use it as a query.   
Exercise 33: Try Some Description Logic Queries  
_____________________________________________________________________________________ 
1. To begin with navigate to the DL Query tab. If it doesn’t exist create it using: Window>Tabs>DL 
Query.    
2.  At the top right of this tab you should see a view that says DL query: and below it Query (class 
expression).    
3 You can enter any DL statement you want in this box and then see all the entities that are subclasses, 
superclasses, and instances of it. As an example, enter:  Customer and purchasedPizza some (hasTopping 
some (hasSpiciness value Hot)). I.e., all Customers who have purchased a Pizza that hasSpiciness 
Hot. At first you may not see anything but don’t worry there is one more step.  
4. Look at the check boxes on the right under Query for. Check Superclasses, Subclasses (although it 
should already be checked by default) and Instances. Now your UI should look like figure 9.1. You may 
notice that owl:Nothing shows up as a subclass. Don’t worry that is actually expected. Remember that 
owl:Nothing is the empty set and the empty set is a subset of every set (including itself) so just as 
owl:Thing is a superclass of every class owl:Nothing is a subclass of every class. If you don’t want to 
see owl:Nothing you can uncheck the box toward the bottom right that says Display owl:Nothing.  
5. Try some additional DL queries such as:  hasTopping some (hasSpiciness value Hot) and 
VegetarianPizza and (hasTopping some (hasSpiciness some (isMilderThan value Hot))). Note that with 
this last query you are taking advantage of the transitive order you defined for the instances of the 
Spiciness class in chapter 6.  
6. You can also do queries for strings in the names of your entities. For example, first do a query simply 
with Pizza in the query window. Then type in Hot in the Name contains field. This should give you all the 
classes and individuals with Hot in their name.  
_____________________________________________________________________________________