Hello all, I would like to ask your advice on the best practice to use the IDs in BaseX, somewhat in the classic style of relationships between records in different nodes or documents. I have not found a simple way to create autoincrement IDs, and indexes generated by BaseX I understand that it's possible to suffer changes in case of optimization actions or database recovery. So I can not count on them. I try to do it using attributes as unique identifiers in repetitive elements, like: <products> . . . <product id="123" name="abc" description="xyz"/> <product id="124" name="bbbb" description="xxxxxxx"/> </products> <product-template> <product id="" name="" description="" ... /> </product-template> When adding a new product, I need to calculate the max from products/product/@id, incremented by 1 and replaced with this value (125) the id of the product template. After that, the updated product template should be inserted in the node products. I try to do all this in a single restxq function, in many ways, but fail. Please give me, first, an general idea of how the problem should be approached in working with BaseX. Many thanks, Ioan