java - Random ID Generator, mapping vs. same-column -


There are some institutions that we want to hide our exact ID from customers - the main reason is that we do not Wish that customers know how many of them are in DB.

By example URL, it says that it is 27th user.

Therefore, I am implementing a solution that provides random ID (which should be unique). In other words, instead of using the unique sequence number, going for a unique non-sequence + is the number solution random

For example from URL, which is actually the 27th user.

My question is here, knowing that some users here may experience this kind of problem, do I use the map or the primary ID of the Random ID column?

For example, if the table does not exist then the 'test' (`id 'int (10) is not unsigned, tap autoncriment,' some else 'varchar (255) null, primary key (` id` ) ID '(' ID` int (10) unsigned non-zero, / * foreign key to test the table * / `parent` integer (11) null, primary key (` id`) when creating the table. , Key `parent` (` parent`))

VS.

 Create a table if not 'test' (/ * specify the random id here / / id id (10) unsigned, some 'else' varchar (255) tap primary key (`id`)) 

For me, more useful later, as I do not need to maintain a map, nor do I use mapped IDs (or intrinsically accurate IDs) DAO / App has to be customized. In both cases, I have to write my own random id generator.

You are right - the latter is a better approach - this is a one-one relationship - for a different table There is no reason I suggest:

  • An index on "fake" user_id, because it will be used for lookup
  • A unique barrier on the columns, make sure To do that duplicate value is not included

Your concern is also not to show actual physical values It is valid for sure that if the database has changed, and the change in the actual primary key value - the user will not have any knowledge of the changes.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -