From Dan Pichelman's comment, the problem is that the client inserts the records into the local database and for this it must determine the primary keys for them. But, considering that all different clients do the same, new PCs will collide when they hit the server.
This is a common problem - these are systems that are physically disabled (at least sometimes) or where there cannot be a single point of failure, for example, in a generator with a common sequence.
Some common solutions:
GUID
Here PK is a 128-bit (or more) random number. The likelihood that any two PCs are the same is extremely small. But to reduce collision changes even further, the GUID algorithm includes seeding with unique machine identifiers (MACs) and time. Two GUIDs created on the same machine will never collide, nor will GUIDs be displayed on machines with different MAC addresses. Most machines and languages have their own functions for generating GUIDs, but JavaScript does not. Cm:
Section naming scheme
In this scheme, PK is again a large number (bit-bit really), and you break it down into a hierarchical one. A good example is the international telephone system (at least to portable numbers). Here the phone number is divided by:
- Country code: for example, USA - 1
- Area code: for example, Sunnyvale - 615
- Subscriber number controlled by the exchange.
In your case, you can split the number into:
- User login (for example, a unique number for each user)
- Session identifier (for example, a number unique to each login per user to distinguish between different sessions of the same user, but in different browsers / computers).
- Serial number
Combining all three, you will have a guaranteed unique PC.
PK License Server
The first two sentences have the advantage of being completely disabled. If you have a connected client, you may have a web service that supplies a PC when the client requests them.
For efficiency, he can return a batch of, say, 100 numbers. It can even be returned when the user logs in.
The client can use them all and request more. There are times when a client forgets the state and leaves a “hole” in the global sequence of the PC. This will almost certainly not be a problem.
Some considerations
Sometimes you may need sequential PKs for the purpose of organizing tables. In this case, you need to order by the customer or at the time of creation? If this is important, you can evaluate the section naming scheme above. Put the client or time as the first section, if necessary. Also add more columns to the table.
Unless you need a fixed partition naming scheme structure, a GUID will work well.
If you need central coordination, use a PC license server.