[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Define no-overlaps constraint based on two integers(range index?)

Michael Kay mike at saxonica.com
Wed Jun 3 12:26:01 PDT 2009


  Define no-overlaps constraint based on two
	integers(range index?)
I think you'll be extraordinarily lucky to find a product that does this for
you automatically, and efficiently. However it's easy enough to check the
condition by hand, with reasonable efficiency so long as you can access
everything in the collection efficiently:

let $ranges :=
  for $doc in collection(...) return
    <range start="{$doc/doc/@start}" end="{$doc/doc/@end}"/>
let $sortedRanges :=
  <ranges>{
    for $range in $ranges order by xs:integer($range/@start) return $range
  }</ranges>
let $valid := empty($sortedRanges/range[xs:integer(@start) le
xs:integer(preceding-sibling::range/@end)])
return $valid
  
If scanning the collection is too expensive, then you can maintain a
document "by hand" that contains the ranges redundantly.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay  
 

> -----Original Message-----
> From: http://x-query.com/mailman/listinfo/talk 
> [mailto:http://x-query.com/mailman/listinfo/talk] On Behalf Of Michael Ludwig
> Sent: 03 June 2009 10:18
> To: http://x-query.com/mailman/listinfo/talk
> Subject:  Define no-overlaps constraint based on 
> two integers(range index?)
> 
> I have a lot of documents in an XML database (Oracle Berkeley 
> DB XML), which look like this:
> 
>    <doc start="100123" end="100456">Huhu</doc>
> 
> Do you see any possibility to define an index on a database (on *any*
> database) such that no two documents with an overlapping 
> period from @start to @end can exist? Both @start and @end 
> are integers. Given the above document, no document may start 
> or end in the interval between
> 100123 and 100456.
> 
> I know this problem is rather general, unrelated to XQuery, 
> and not even specific to DBXML, of which I've already 
> consulted the forum:
> 
> http://forums.oracle.com/forums/message.jspa?messageID=3482507
> 
> I also know this problem could have an XQuery solution coded 
> at the application level, based on equality indices on @start 
> and @end.
> 
> Pointers to better places to ask this are as welcome as hints 
> to a solution. I'm not sure what this kind of index is 
> called; I thought of "contiguity index", or "range index", or 
> "interval index", but can't find much in Google. Does anyone know?
> 
> Michael Ludwig
> _______________________________________________
> http://x-query.com/mailman/listinfo/talk
> http://x-query.com/mailman/listinfo/talk



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.