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