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 am designing a database layout for a site. Agents registering on the site will have to enter their address including the country. Later I will build a dashboard where you would be able to search/sort by fields (including country field) and produce various reports (which includes country as well).

Is it better to store country name directly in a table or have a separate table with countries and only store the id of a country?

share|improve this question

closed as off-topic by RolandoMySQLDBA, StanleyJohns, Mark Storey-Smith, ConcernedOfTunbridgeWells, bluefeet Aug 9 '13 at 20:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – StanleyJohns, Mark Storey-Smith, bluefeet
If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 1 down vote accepted

It's better to have a separate table. That way your data will be normalized.

In your specific case you most likely want a list of countries the user can select from (eg. it's not a free form field). By having it be a separate table and referencing the country id you can setup a foreign key constraint to your countries table. This way your data will always be in sync as user's will not be able to enter a country that does not exist.

share|improve this answer

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