Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 560021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:17:57+00:00 2026-05-13T12:17:57+00:00

There’re a few entities that we wish to hide its exact ID from the

  • 0

There’re a few entities that we wish to hide its exact ID from the customers – the main reason is that, we do not want customers to know how many of them are in the DB.

e.g. from the URL, http://mydomain/user/get/27, it says that this is the 27th user.

Therefore, I am implementing a solution that assigns random ID (that has to be unique). In another words, instead of using unique sequence number, am going for an unique non-sequence+randomize number solution.

e.g. from the URL, http://mydomain/user/get/8534023, which is actually the 27th user.

My question here is, knowing that some users here may have experience on the similar problem, shall I use a map or assign the random ID to the primary key column?

e.g.

CREATE TABLE IF NOT EXISTS `test` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `somethingElse` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
)

CREATE TABLE IF NOT EXISTS `map` (
  `id` int(10) unsigned NOT NULL,
  /* Foreign Key to test table */
  `parent` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `parent` (`parent`)
)

VS.

CREATE TABLE IF NOT EXISTS `test` (
  /* Assign random ID here */
  `id` int(10) unsigned NOT NULL,
  `somethingElse` varchar(255) NOT NULL
  PRIMARY KEY (`id`)
)

To me, the latter comes to be more handy, as I do not have to maintain a map, nor I have to customize the DAO/application to use the mapped ID (or the exact ID internally). For both case, I have to write my own random ID generator.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:17:57+00:00Added an answer on May 13, 2026 at 12:17 pm

    You are correct – the latter is the better approach. It is a one-to-one relationship – there’s no reason to have a separate table. I recommend having:

    • an index on the “fake” user_id, as it will be used for lookups
    • A UNIQUE constraint on the column, to ensure that duplicate values are not inserted

    Your concern is also valid to not expose actual primary key values. It ensures that if the database changed, and the actual primary key value changed – the user would have no knowledge of the change.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is my code that I want to alert test once when mousemove ,
There is a moment in my app, that I need to force to show
There is a column that exists in 2 tables. In table 1, this column
There is a directed graph having a single designated node called root from which
There are two intents on the receiver side which are called from the same
There are a lot of blogs saying that a hasOwnProperty check should be used
For some reason, after submitting a string like this Jack’s Spindle from a text
There are times when the document the user is looking for is not present
There are some stdlib functions that throw errors on invalid input. For example: Prelude>
There is a component that I have been using since IE7 and had never

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.