Lasitha Yapa
Lasitha Yapa

Reputation: 4609

User Friendly Unique Identifier For DynamoDB

In my DynamoDB table named users, I need a unique identifier, which is easy for users to remember.

In a RDBMS I can use auto increment id to meet the requirement.

As there is no way to have auto increment id in DynamoDB, is there a way to meet this requirement?

If I keep last used id in another table (lastIdTable) retrieve it before adding new document, increment that number and save updated numbers in both tables (lastIdTable and users), that will be very inefficient.

UPDATE

Please note that there's no way of using an existing attribute or getting users input for this purpose.

Upvotes: 1

Views: 311

Answers (3)

so-random-dude
so-random-dude

Reputation: 16505

Docker container naming strategy might give you some idea. https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go It will result in unique (limited) yet human friendly

Examples

awesome_einstein
nasty_weinstein
perv_epstein

A similar one: https://github.com/jjmontesl/codenamize

Upvotes: 0

Matthew Pope
Matthew Pope

Reputation: 7669

Since it seems you must create a memorable userId without any information about the user, I’d recommend that you create a random phrase of 2-4 simple words from a standard dictionary.

For example, you might generate the phrase correct horse battery staple. (I know this is a userId and not a password, but the memorability consideration still applies.)

https://imgs.xkcd.com/936/

Whether you use a random number (which has similar memorability to a sequential number) or a random phrase (which I think is much more memorable), you will need to do a conditional write with the condition that the ID does not already exist, and if it does exist, you should generate a new ID and try again.

Upvotes: 2

Charles
Charles

Reputation: 23793

email address seems the best choice...

Either as a partition key, or use a GUID as the partition key and have a Global Secondary Index over email address.

Or as Matthew suggested in a comment, let the users pick a user name.

Upvotes: 0

Related Questions