Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unique identifiers for users

If I have a table of a hundred users normally I would just set up an auto-increment userID column as the primary key. But if suddenly we have a million users or 5 million users then that becomes really difficult because I would want to start becoming more distributed in which case an auto-increment primary key would be useless as each node would be creating the same primary keys.

Is the solution to this to use natural primary keys? I am having a real hard time thinking of a natural primary key for this bunch of users. The problem is they are all young people so they do not have national insurance numbers or any other unique identifier I can think of. I could create a multi-column primary key but there is still a chance, however miniscule of duplicates occurring.

Does anyone know of a solution?

Thanks

like image 472
christophmccann Avatar asked Apr 08 '10 18:04

christophmccann


People also ask

What is unique user identifier?

A unique identifier (UID) is a numeric or alphanumeric string that is associated with a single entity within a given system. UIDs make it possible to address that entity, so that it can be accessed and interacted with.

What is the unique identifier for device users?

On Android, the device ID is the Android Advertising ID (AAID). Users are able to access their AAID within the settings menu under 'Google - Ads,' as well as reset the ID, and opt-out of ad personalization.

What are the three different types of unique identifiers?

serial numbers, assigned incrementally or sequentially, by a central authority or accepted reference. Hash functions: based on the content of the identified object, ensuring that equivalent objects use the same UID. Random number generator: based on random process.

How do you get unique identifiers?

The simplest way to generate identifiers is by a serial number. A steadily increasing number that is assigned to whatever you need to identify next. This is the approached used in most internal databases as well as some commonly encountered public identifiers.


1 Answers

I would say that for the time being keep an auto increment for the user ID.

When you do have that sudden rush of millions of users, then you can think about changing it.

In other words, solve the problem when you have it. "premature optimization is the root of all evil.".

To answer the question - some auto increments will allow you to seed the auto increment, so you can get different auto increments on the different nodes. This will avoid the problem, while still allowing use of an auto increment.

like image 96
Oded Avatar answered Oct 21 '22 23:10

Oded