G
G
Gennady Kruglov2016-07-22 05:10:30
SQL
Gennady Kruglov, 2016-07-22 05:10:30

How to generate an integer unique ID for a multi-user system?

How to generate an integer unique ID for a multi-user system?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Rsa97, 2016-07-22
@Rsa97

Why didn't you like autoincrement IDENTITY (1,1)? It is generated by means of the server itself and does not give duplicates during multi-user work. The value may not be consistent, but it will be unique for sure.

I
Iron Bug, 2016-07-22
@rare

You can create a separate service for generating id, and your applications will access it. Something like twitter-snowflake.
For .net, there are libraries for generating keys, all that remains is to wrap them, for example, in a rest-service.
https://www.nuget.org/packages/IdGen/2.0.0-rc
https://www.nuget.org/packages/RustFlakes/

K
Konstantin Tsvetkov, 2016-07-22
@tsklab

Use ranges for users (as is done with per-replica replication) or a prefix.

G
guras256, 2016-07-26
@guras256

I don’t really understand the emphasis on SIMULTANEOUSNESS, why do you need to think about it, the database will think for you, then you need it ..
in extreme cases, you can make an api method that will pull the sequence in the database and return a unique identifier, so the client will know under what id should he save the card with

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question