Hi Ioan,
In BaseX exist random:uuid() function. Do you use it, or another way to generate GUID?
In our own use case, we sometimes use UUIDs and sometimes create our own IDs.
If you don't need an easily readable ID, and none that is incremental, I would recommend the use of random:uuid() because it's the easiest solution.
Is there any way to generate such unique identifiers automatically when inserting a new record?
What do you call a "record" in your terminology?
By looking at your example, you could e.g. add a UUID as follows before storing it the XML fragment in the database:
<product id="{ random:uuid() } " ...
Hope this helps, Christian