Let's say I have a service where I provide user registration. The user chooses a ID. Now if I already have someone who is registered against that ID, I will inform the user that this ID is already used so try something else.
Now I want to provide some suggested IDs to the user based on what information I have while signing up(name, DOB, timestamp etc). How do I provide unique suggestions efficiently?
The obvious idea is to generate some suggestions(like taking user initials and DOB) and then check if they exist in the database, and suggest only those which aren't exisiting. But this is a very inefficient way of doing it I reckon. Is there any algorithm for this? How does something like gmail provide suggestions for email ID to a user while signing up?
As an example, if I am user John Doe and I want to sign up as John, if it is not available then i should get suggestions like J.doe, John.d, JD01(assuming birthdate)