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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:43:59+00:00 2026-06-16T22:43:59+00:00

Hmmm I don’t know much about database architecture but I really don’t understand what’s

  • 0

Hmmm I don’t know much about database architecture but I really don’t understand what’s in CTO’s mind but he insists on using character as the
column type of the primary key of all of the tables we use.
But the primary keys still look like this – > 1,2,3… etc. They are numeric.
so I use integer + auto_increment for synthetic PK

But CTO says it’s bad bc he can’t issue queries using LIKE condition on PK ?!

  1. Is it Ok to use character for PK especially when your PK is numeric ?
  2. Is it right to use like condition on PK?

PS – so instead of auto increment/trigger,sequence CTO issues select query that fetches
the biggest value from the table and he adds 1 and then he converts that value into string
then stores it.

Edit
Thank you for your help ! But I need to convince him that it’s going to be a disaster.
I’ve only been taught that this(character 4 PK in a case like this) is a bad idea.
He’s argument is …
1. The character PK won’t take up much space.
2. The database query optimiser would have to re-read your query if you used int type PK
because you would have to issue something like
"select * from employee where name like 'somename'
and
Select * from employee where id = 6.
because the where clause changes.
What he strongly argued that we use was something like
"select * from employee where @columnName like @value"
He said this way, the query optimiser would run better.

How can I prove or give him some valid reasons to change his mind ?

Thank you : )

  • 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-06-16T22:44:00+00:00Added an answer on June 16, 2026 at 10:44 pm

    Lots of reasons why your CTO is making a mistake with that decision; let me cover a few:

    1. As you’ve noted, you have to take extra steps to generate a new auto-incrementing PRIMARY KEY. That’s a computing cost, and it also increases the likelihood that it will be inconsistently applied at some point in the future.

    2. Characters will cost more in disk space once they exceed 4 characters (in other words, 12345 is a lot cheaper to store than “12345”).

    3. IF you are using a clustered index on your Primary Key (which is the default for some RDBM’s), sorting for characters is completely different than sorting an integer:

    Characters: 1, 10, 101, 11,12,13,14,15…
    Numeric: 1,2,3,4…

    If you’re inserting the max numeric value as a character, you’re shredding your indexes. Not an insurmountable problem, but more wasted computing power to clean up.

    As for your second question about using LIKE on a PRiMARY KEY, I cant think of a reason why you would do something like that; if you need the power of LIKE, it’s usually because you’ve assigned some sort of significance to the column being used as the PRIMARY KEY, which means you need to expose it to your end user. IF that’s the case, then I would use a surrogate auto-incrementing numeric primary key, and expose some form of ID to the user.

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

Sidebar

Related Questions

Hmmm I don't know how to clearly state the title. hopefully the following explanation
Hmmm...crappy question, but I didn't know how to phrase this: I have a sweet
I know that an empty div is not hmmm entirely semantical. But I was
I'm fairly new to the DI concept, but I have been using it to
Well, there are other ways (hmmm... or rather working ways) to do it, but
Hmmm All the answers I've seen here suggest that this should work, but... Is...
Hmmm. Okay after revisiting PInvoke, I'm sure that I don't quite get it :-/
Hmmm... I have read about this issue on various other threads here on stackoverflow
From reading on Stack Overflow I've seen that many of you don't recommend using
Hmmm... the Java Iterator<T> has a remove() method but not a replace(T replacement) method.

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.