Create two tables.
One contains everything about the city.
One contains a bunch of names for cities and an association of foreign keys that have names with the identifier of the first table. Thus, you have a relationship to each other between cities and cities.
Now the only problem is to distinguish one name for each city, which is the preferred name. We can do this in several ways: 1) the first table can have fk in the second table, which contains the identifier of the preferred name. However, this creates a cyclical dependency. So better, 2) just add the boolean / bit column to the second table, is_preffered.
create table city (id not null primary key, other columns ) ; create table city_name ( id not null primary key, city_id int references city(id), name varchar(80), is_preferred bool ) ;
Then, to get all the names with the preferred name:
select name from city_names where city_id = ? order by is_preffered desc, name;
This has an additional advantage: if you do not cover every city and city, you can use the second table to compare cities / villages / counties that you do not cover to the main cities that you do:
insert into city_name(city_id, name) values ( $id-for-New-York-City, 'New York'), ( $id-for-New-York-City, 'Manhattan'), ( $id-for-New-York-City, 'Big Apple'), ( $id-for-New-York-City, 'Brooklyn');
tpdi
source share