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 3937064
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:01:31+00:00 2026-05-20T00:01:31+00:00

Question Is it a good rule of thumb for database IDs to be meaningless?

  • 0

Question

Is it a good rule of thumb for database IDs to be “meaningless?” Conversely, are there significant benefits from having IDs structured in a way where they can be recognized at a glance? What are the pros and cons?

Background

I just had a debate with my coworkers about the consistency of the IDs in our database. We have a data-driven application that leverages spring so that we rarely ever have to change code. That means, if there’s a problem, a data change is usually the solution.

My argument was that by making IDs consistent and readable, we save ourselves significant time and headaches, long term. Once the IDs are set, they don’t have to change often and if done right, future changes won’t be difficult. My coworkers position was that IDs should never matter. Encoding information into the ID violates DB design policies and keeping them orderly requires extra work that, “we don’t have time for.” I can’t find anything online to support either position. So I’m turning to all the gurus here at SA!

Example

Imagine this simplified list of database records representing food in a grocery store, the first set represents data that has meaning encoded in the IDs, while the second does not:


ID’s with meaning:

Type
1 Fruit
2 Veggie

Product
101 Apple
102 Banana
103 Orange
201 Lettuce
202 Onion
203 Carrot

Location
41 Aisle four top shelf
42 Aisle four bottom shelf
51 Aisle five top shelf
52 Aisle five bottom shelf

ProductLocation
10141 Apple on aisle four top shelf
10241 Banana on aisle four top shelf
//just by reading the ids, it's easy to recongnize that these are both Fruit on Aisle 4

ID’s without meaning:

Type
1 Fruit
2 Veggie

Product
1 Apple
2 Banana
3 Orange
4 Lettuce
5 Onion
6 Carrot

Location
1 Aisle four top shelf
2 Aisle four bottom shelf
3 Aisle five top shelf
4 Aisle five bottom shelf

ProductLocation
1 Apple on aisle four top shelf
2 Banana on aisle four top shelf
//given the IDs, it's harder to see that these are both fruit on aisle 4

Summary

What are the pros and cons of keeping IDs readable and consistent? Which approach do you generally prefer and why? Is there an accepted industry best-practice?

——– edit ( helpful background info from comments, below ): ——–

In our tables, the Primary Key is always an ID field containing a unique integer. At first, that integer was arbitrary. Over time, some of these IDs naturally took on meaning among developers/testers. During a recent refactor, certain developers also took time to make all IDs easier to recognize. It made everyone’s job 100X easier. Some people (who don’t actually use the data/code) vehemently disagreed for theoretical reasons. In practice, not one of those objections are holding true. Moreover, all developers using the data agree that it’s now significantly easier to maintain.

I’m looking for (but haven’t seen) a defensible argument against using immediately recognizable IDs in a data-centric environment.

  • 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-20T00:01:32+00:00Added an answer on May 20, 2026 at 12:01 am

    There are several problems with using database IDs to encode information about a row. If you want your carrots to have an “ID” of 203, you should add a product_id column (for example) and put this information there instead. Why?

    1. By customizing your IDs, you have to add domain-specific code that manages your IDs and you can’t rely on database features like auto-incrementing or UUIDs.
    2. If you ever have to change your classification, it will mess up your table relations, browser bookmarks, search engine results, etc.
    3. It’s not common practice — so when you put application- or domain-specific data into the ID field, it will be assumed by many that this is meaningless information, when it isn’t. You will need a data dictionary (and you will have to ensure that people read the data dictionary) to note the fact that this is valuable information.

    The only required purpose of an ID is to uniquely identify a row within a table. If it can provide good lookup performance, that’s a bonus, and if it can be compactly stored, that’s another bonus. But it shouldn’t contain any information about the entity in the row it identifies, other than the unique identifier of that entity.

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

Sidebar

Related Questions

Question What is a good way of assigning a default value to an optional
Question: Is there a good free & open solution out there for revision control
Does anyone know of a good reference or rule of thumb for when to
here is a good question: I have an application compiled for iPhone OS 2.21.
I got a question about good practice. I'm making a simple game and, I'm
This can be a good question for finding bugs. No? Okay for beginners at
I couldn't seem to find a good question on SO, or a good Google
I feel this is not a very good question to post on SO, but
This question is about good programming practices and avoiding potential holes. I read Joshua
Maybe the question sound not good or too simple. But not for me in

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.