We are already using UUIDs for file names. However we want, for example, guaranteed uniqueness across text names contained in elements within documents of a collection.
On Jan 9, 2016, at 12:52 PM, "Christian Grün" christian.gruen@gmail.com wrote:
Hi E. Wray,
What is the best practice in BaseX to implement a uniqueness constraint similar to a RDBMS?
Using UUIDs has become our favorite solution. An alternative is to assign an incrementing integer, and e.g. store the highest assigned value in the root node. If you want to assign arbitrary values, you’ll need to check if the value has already been assigned:
let $id := 'sjdhsj' return if(//item[@id = $id])) then ( error( (), "ID is not unique: " || $id) ) else ( ... )
If your database has an up-to-date attribute index, this should be pretty fast.
Christian