I'm using Neo4J as the backend to an application that is effectively a content management platform. Users can upload assets (such as PDFs) and manage the relationships between assets.
To aid the identification of assets, we create a unique ID and want them to be human friendly. For example, documents might have use "DO-003456". The main reason for these IDs is that document title aren't unique and we could have alternate titles in other languages.
I'm familiar with the internal ID() concept and the cons that go with using those. I'm also familiar with the true UUID approach using apoc functions or something similar. The problem with the UUID approach is the values aren't really human friendly. Imagine the frustration and human errors involved in reading off a 36 bit hexadecimal number when asking a coworker to open a particular document.
The approach I use currently is a basic incrementor with a prefix. When creating a new entry the process is basically..
-
Get the current max integer portion, after removing the prefix portion.
MATCH (d:Doc)
RETURN MAX(toInteger(substring(d.GUID,2))) as GUID
(the assumption here is that "Doc" labels all use the same GUID prefix) -
Create a new entry using prefix + (GUID+1)
This approach works, but could run into a race condition in the rare event of simultaneous inserts.
Any suggestions on alternate approaches to managing the creations of IDs that are in a form like "Prefix-integer".
Thanks..