In my application each of my users is required to select a suburb to which to associate their profile. The users
table has a field suburb_id
and a table called suburbs
has both an id
and name
field.
Our suburbs
table contains most of the suburbs that we will need, however occasionally users will need to enter suburbs that we don't have in our table, or have popped up since we populated our table.
What is the best way in terms of database design to solve this problem.
I had considered changing the field suburb_id
to just suburb
and then testing in the application whether it was an integer or a string - if it was an integer the application would assume it is related to an item in the suburbs
table, if it was a string it would assume otherwise. However, if a user was to simply enter an integer in the suburb
field then the application would obviously mistake it and try to match it up with a value in the table.
Is that an acceptable way to deal with the problem (it seems gimmicky to me - I am sure there must be a better solution).
EDIT: I would also like to avoid inserting data provided from users into the suburbs
table (even if flagged) as I don't want to affect the quality of the suburbs data we have.