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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:56:47+00:00 2026-06-12T08:56:47+00:00

I have read many articles about the battle between natural versus surrogate primary keys.

  • 0

I have read many articles about the battle between natural versus surrogate primary keys.
I agree in the use of surrogate keys to identify records of tables whose contents are created by the user.

But in the case of supporting tables what should I use?

For example, in a hypothetical table “orderStates”.
The valuse in this table are not editable (the user can’t insert, modify or delete this values).

If you use a natural key would have the following data:

TABLE ORDERSTATES
{ID: "NEW", NAME: "New"}
{ID: "MANAGEMENT" NAME: "Management"}
{ID: "SHIPPED" NAME: "Shipped"}

If I use a surrogate key would have the following data:

TABLE ORDERSTATES
{ID: 1 CODE: "NEW", NAME: "New"}
{ID: 2 CODE: "MANAGEMENT" NAME: "Management"}
{ID: 3 CODE: "SHIPPED" NAME: "Shipped"}

Now let’s take an example: a user enters a new order.

In the case in which use natural keys, in the code I can write this:

newOrder.StateOrderId = "NEW";

With the surrogate keys instead every time I have an additional step.

stateOrderId_NEW = .... I retrieve the id corresponding to the recod code "NEW"

newOrder.StateOrderId = stateOrderId_NEW;

The same will happen every time I have to move the order in a new status.

So, in this case, what are the reason to chose one key type vs the other one?

  • 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-12T08:56:49+00:00Added an answer on June 12, 2026 at 8:56 am

    The answer is: it depends.

    In your example of changing the order state inside your code, ask yourself how likely it is that you would create constants for those states (to avoid making typos for instance). If so, both will accomplish the same.

    In the case that a new order state gets submitted via a form, you would build the drop down (for example) of possible values using either the natural or surrogate key, no difference there.

    There’s a difference when you’re doing a query on the order table and wish to print the state for each order. Having a natural key would avoid the need to make another join, which helps (albeit a little).

    In terms of storage and query performance, the surrogate key is respectively smaller and faster (depending on the table size) in most cases.

    But having said all that, it just takes careful consideration. Personally I feel that surrogate keys have become something like a dogma; many developers will use them in all their tables and modeling software will automatically add them upon table creation. Therefore you might get mixed reactions about your choice, but there’s no hard rule forbidding you to use them; choose wisely 🙂

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

Sidebar

Related Questions

I have read so many articles about integration and yet i did not found
I have read many about REST api in php articles. but I still get
I have read many articles about vertical centering but I’m afraid not many of
I have read many articles about XML parsing in Android. However, all of them
I have read many articles about linq to sql performance. The result which i
I am beginning to write a Facebook application. I have read many articles about
I have just read many, many articles on SO about hashing passwords with salt
I have read many MSDN articles about assembly signing and I haven't found nothing
I have read many articles, discussions and tutorials about using utf-8 charset in mysql.
I have read through many posts and articles about styling a Wordpress Gallery, but

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.