Search code examples
semantic-webowlontologyprotege

SPARQL individuals queries for Pizza ontology


I wrote this query but it does't work. Anyone knows what is the problem.

PREFIX : <http://www.semanticweb.org/ontologies/2009/pizza.owl#>
SELECT ?X ?Y
        WHERE {?X :hasCountryOfOrigin "Italy".
               ?Y :hasCalorificValue "400"}

Solution

  • According to the Pizza ontology tutorial here, there are two main issues with your query:

    1. hasCountryOfOrigin is an object property, thus, the values can't be literals. Italy is an individual, thus, you have to use the correct URI, probably http://www.semanticweb.org/ontologies/2009/pizza.owl#Italy
    2. The data property hasCalorificValue has values of type integer, i.e. literals should be used like "400"^^xsd:integer (or maybe xsd:int, depends on what you've chosen in Protege)
    3. Both triple patterns in your query are not connected, i.e. no shared variable. I don't see the goal of your query.
    PREFIX : <http://www.semanticweb.org/ontologies/2009/pizza.owl#>
    SELECT ?X ?Y
            WHERE {?X :hasCountryOfOrigin :Italy.
                   ?Y :hasCalorificValue "400"^^xsd:integer}