0

I have data for 20 breeds as individual and their costs, energy level, adaptability level, hypoallergenic, and the purposes of having them as object properties. I want to retrieve all object properties in individual.

so far this is my query:

PREFIX dog: <http://www.owl-ontologies.com/guguk_test.owl#>
SELECT *
WHERE {
    ?dog dog:hasAdaptability ?adaptability .
    ?dog dog:hasCost ?cost .
    ?dog dog:hasEnergy ?energy .
    ?dog dog:hasHypoallergenic ?hypoallergenic .
    ?dog dog:hasPurpose ?purpose .
}

the result show all the breeds (individual) with all the object properties

this is screenshot of the result screenshot of the result

I need to select just 1 breed (individual) and object properties of that breed.

I already try this query but the result was: no matches found.

PREFIX dog: <http://www.owl-ontologies.com/guguk_test.owl#>
SELECT *
WHERE {
    ?dog dog:hasBreeds dog:Basenji .
    ?dog dog:hasAdaptability ?adaptability .
    ?dog dog:hasCost ?cost .
    ?dog dog:hasEnergy ?energy .
    ?dog dog:hasHypoallergenic ?hypoallergenic .
    ?dog dog:hasPurpose ?purpose .
}
TallTed
  • 9,069
  • 2
  • 22
  • 37
  • We don't know your ontology, so how can we know why the second query doesn't match? Obviously either the property `hasBreeds` is wrong or there is no `dog:Basenji` ... or maybe one of the other properties has no values for that breed...your see, without the data -> impossible to help! – UninformedUser Jul 03 '18 at 18:11
  • Screenshots are often not looked at. If you had provided your results as text, I'm sure @AKSW would have seen what I did. – TallTed Jul 03 '18 at 18:32
  • ... now that I see the answer of @TallTed ... is there no property `hasBreeds` at all in your ontology? From your small unreadable screenshot, I can`t see how a particular dog is related to a breed... – UninformedUser Jul 03 '18 at 18:51

2 Answers2

2

Try this...

PREFIX dog: <http://www.owl-ontologies.com/guguk_test.owl#>

SELECT *
WHERE {
    VALUES ?dog { dog:Basenji } .
    ?dog dog:hasAdaptability ?adaptability .
    ?dog dog:hasCost ?cost .
    ?dog dog:hasEnergy ?energy .
    ?dog dog:hasHypoallergenic ?hypoallergenic .
    ?dog dog:hasPurpose ?purpose .
}
TallTed
  • 9,069
  • 2
  • 22
  • 37
0

Note that you can use variables for properties too. This query will fetch them all, even if you change your ontology :

PREFIX dog: <http://www.owl-ontologies.com/guguk_test.owl#>

SELECT * WHERE {
    dog:Basenji ?property ?value
}

Alternatively, you can use the BIND operator to assign the breed you want to retrieve to a variable.

PREFIX dog: <http://www.owl-ontologies.com/guguk_test.owl#>

SELECT * WHERE {
    BIND (dog:Basenji AS ?dog)

    ?dog ?property ?value
}
Richard-Degenne
  • 2,892
  • 2
  • 26
  • 43