There a few different things that you could mean here. You could
- declare that the range of a property is a value within some range;
- assert that for some particular individual, its values of a particular property are within some range;
Given that you said that:
what i need is that when i SPARQL my db, i should make query that will find all materials that have let's say YieldStrength > 350. If it's in that interval even partial it should be a valid result.
Using two properties
I think that your best best is to use two properties (e.g., minStrength
/maxStrength
). This means that you can have data like:
metal72 minStrength 200 ;
maxStrength 400 .
Then you can write a query with a pattern like
?metal minStrength ?min ;
maxStrength ?max .
filter( ?min <= 350 && 350 <= ?max )
I think this most closely matches the idea you're trying to capture, because it sounds like each metal is actual associated with some range of values. Where some metals can have exact values (and not a range), you can still use this approach, by putting in your data:
Zn minStrength 420 ;
maxStrength 420 .
Then all of your metals are consistent (they all have a min value and a max value), and your queries won't have to worry about different cases.
Using ranges, and querying the RDF serialization of the OWL
Now, while I think that the previous approach makes more sense, you can represent data ranges in OWL. For instance, if there's a hasStrength
property, you could say that some metal has strengths only within some range by using a restriction like
metal72 a (hasStrength only int[>=200,<=400])
In Protégé this looks like:
What this actually means though is not that the metal has some strength range, but that for any triple of the form metal72 hasStrength x
, the value of x
must be an int
in the range [200,400]
, or else the data is inconsistent. This is obviously different than saying that the metal has a strength range.
The OWL ontology can be serialized in RDF, and then you can query the RDF using SPARQL. You'll need to know what the RDF looks like though. In this case, it's:
:metal72 a owl:NamedIndividual , :Metal ;
a [ a owl:Restriction ;
owl:allValuesFrom [ a rdfs:Datatype ;
owl:onDatatype xsd:int ;
owl:withRestrictions ( [ xsd:minInclusive
200 ] [ xsd:maxInclusive
400 ] )
] ;
owl:onProperty :hasStrength
] .
That's a bit much, but you can query against it with SPARQL with a query like the following. It will return any ?metal
which has a type hasStrength only int[>=min,<=max]
, where min ≤ 350 ≤ max
.
prefix metal: <http://www.example.org/metal#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
select ?metal where {
?metal a metal:Metal ;
a [ owl:allValuesFrom [ owl:withRestrictions [ rdf:rest* [ xsd:minInclusive ?min ] ] ;
[ rdf:rest* [ xsd:maxInclusive ?max ] ] ] ;
owl:onProperty metal:hasStrength ] .
filter( ?min <= 350 && 350 <= ?max )
}