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

  • Home
  • SEARCH
  • 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 8533395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:57:21+00:00 2026-06-11T09:57:21+00:00

How should I store States and Countries? Option 1) I could create a database

  • 0

How should I store States and Countries?

Option 1) I could create a database table called states, and have ‘id’, ‘state’, and ‘state_abbr’. I could then reference that by ‘id’ in the users table.

Option 2) I could create a PHP array and use that to populate the states drop down menu, and avoid querying the database altogether. The key for the array would be the value inserted in the database for that user.

States don’t change, and so the data should be static. What’s the best way to store this information and why? Wouldn’t a PHP array be faster? Why does it seem like the database is the best way to store it then?

Thoughts?

  • 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-11T09:57:22+00:00Added an answer on June 11, 2026 at 9:57 am

    A wise database designer once told me, “Everything you know about state codes is wrong.”

    • These are two-letter codes, not abbreviations. (The abbreviation for California is “Calif.”, and the abbreviation for Ohio is “Ohio”.)
    • There are more than 50 of them.
    • Not all of the two-letter codes refer to states. They also refer to “possessions” like “Federated States of Micronesia” and “Palau”.
    • They’re not unique. One two-letter code, AE, refers to four different military “states” (Armed Forces Europe, Armed Forces Canada, Armed Forces Middle East, and Armed Forces Africa).
    • Military “state” codes may change as troop strength changes. Send a few hundred thousand troops into Africa, and you’re likely to see the code for Armed Forces Africa change from “AE” to “AF”.
    • There are a dozen or so territories that aren’t yet in this list. Some of these are of strategic interest (Wake Island, Midway Islands, etc.), and their status could easily change.

    Given that you’re not likely to know all these things about such a common thing as USPS state codes, it just makes more sense to store them in a table. Tables are easier to maintain at run time than a PHP array is.

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

Sidebar

Related Questions

I may have to store some i18n-ed data in my database using XML if
i wanted to know where we should store the db in our project and
I'm working on a project of which I should store constant multi dimensional arrays.I
how should I store user data in asp.net mvc? Let's say a user want
How should I store Birthdate's in MySQL so that I can easily update everyone's
Using MySQL should I store time data as an Int which would be the
In my application I use some icons. Where should I store the path of
Ex. in Symfony 1: http://www.symfony-project.org/jobeet/1_2/Doctrine/en/06#chapter_06_custom_configuration Where should I store global data, which file?
How should I correctly store IP address list with addresses which are subnets to
Where should an JDBC-compliant application store its SQL statements and why? So far, I

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.