Take the 2-minute tour ×
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. It's 100% free, no registration required.

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
add comment

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.

1 Answer

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
add comment

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