Hello Leyla,

Maybe I've missed something but the query yon need does not require even
using subqueries, just a plain SPARQL:

SELECT * WHERE {
  ?sub xxx:hasPrice ?obj, ?obj1 .
  ?obj xxx:hasMinPrice ?min . ?obj xxx:hasMaxPrice ?max .
  ?obj1 xxx:hasMinPrice ?min1 . ?obj1 xxx:hasMaxPrice ?max1 .
  FILTER ((obj != ?obj1) && (?min1 >= ?min) && (?max1 <= ?max))
}

Best Regards,

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com

On Mon, 2009-11-30 at 14:42 +0100, [email protected]
wrote:
> Hello there,
> 
> I have an object property which can appear more than once. It defines min
> and max values for prices which should not overlap and I need to check it.
> 
> <xxx:Toy rdf:ID="car_1">
>   <xxx:hasPrice>
>     <xxx:Price rdf:ID="price_1">
>       <xxx:hasMinPrice>300.0</xxx:hasMinPrice>
>       <xxx:hasMaxPrice>450.0</xxx:hasMaxPrice>
>     </xxx:Price>
>   </xxx:hasPrice>
>   <xxx:hasPrice>
>     <xxx:Price rdf:ID="price_2">
>       <xxx:hasMinPrice>100.0</xxx:hasMinPrice>
>       <xxx:hasMaxPrice>200.0</xxx:hasMaxPrice>
>     </xxx:Price>
>   </xxx:hasPrice>
> </xxx:Toy>
> 
> I think I can do it with SPARQL and loops. For each price I need to look
> at the others and see if values are overlapping so I coudl get the set of
> all overlapping elements. Something like:
> 
> FOR EACH (SELECT * WHERE {
>   ?sub xxx:hasPrice ?obj .
>   ?obj xxx:hasMinPrice ?min . ?obj xxx:hasMaxPrice ?max .
> })
> {
>   SELECT * WHERE {
>   ?sub1 xxx:hasPrice ?obj1 .
>   ?obj1 xxx:hasMinPrice ?min1 . ?obj1 xxx:hasMaxPrice ?max1 .
>   FILTER ((?sub = ?sub1?) && (obj <> ?obj1) &&
>     (?min1 >= ?min) && (?max1 <= ?max))
> }
> 
> Is something like that possible? How can I accomplish this check? do I
> have to do it programatically, perhaps in Java, with regular loops?
> 
> Thanks in advanced,
> 
> LG
> 
> P.D. My apologies if this is not the right mailing-list for this question,
> if it is not, maybe you can suggest me one?
> 
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Virtuoso-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/virtuoso-users


Reply via email to