Search code examples
sparqldbpedia

Adding more information on a simple SPARQL query


I've been running some examples with SPARQL, and it looks pretty cool.

I'm using for the moment http://dbpedia.org/snorql

I'm trying to query Salty Desserts over there.

I can list Desserts using

     SELECT ?food 
     WHERE {   
       ?food rdf:type <http://dbpedia.org/class/yago/Desserts>
     }
     ORDER BY ?name

How do I actually put on the query that the food has to be salty? Sorry if this seems to be a dumb question.


Solution

  • If it were sufficient for it to have salt on the list of ingredients:

     SELECT DISTINCT ?food
     WHERE { 
       ?food rdf:type <http://dbpedia.org/class/yago/Desserts> .
       ?food <http://dbpedia.org/ontology/ingredient> :Salt .
     } ORDER BY ?food
    

    Taste seemed a good lead, but:

    SELECT DISTINCT ?property ?hasValue ?isValueOf
    WHERE {
      { <http://dbpedia.org/ontology/taste> ?property ?hasValue }
      UNION
      { ?isValueOf ?property <http://dbpedia.org/ontology/taste> }
    } ORDER BY ?property ?hasValue ?isValueOf
    

    All of this tested on DBPedia snorql