Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an inventory with three numbered groups like so:

Group 1: 0-999 Group 2: e0-e999 Group 3: v0-v999

Can I simply make a one-column table to store this information and make that column the primary index (needed?), or should I make it two columns.


code (primary)


 code_id    code
    1        000
    2        016
    3        760
    4        433
    5        e221
    6        e011
    7        v999
    8        v003
share|improve this question
up vote 0 down vote accepted

You can use the one-column approach for simplicity. However, what happens when a code is changed? Will you have to update all related tables to have the new code?

Using an integer ID is the best choice for a primary key because it's small and efficient (strings have to be reduced/hashed to an integer before they are used as an index). Also, updating a code will happen in only one place and be reflected in all related tables automatically.

So I would recommend your second option for the sake of speed and to avoid a cascading update.

share|improve this answer
Thank you, you're right. I wasn't thinking it through. – James Huckabone Jun 4 '13 at 16:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.