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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:42:07+00:00 2026-05-29T09:42:07+00:00

A given location (city), can have a name and also other aliases by which

  • 0

A given location (city), can have a name and also other aliases by which it can be known. I need to model this in a database.

Search can be executed using either city or any of its alias:

For e.g.

City:

  • name: Los Angeles
  • alias: LA

When specifying the search criterion, I can either specify LA or Los Angeles, and it should return the same result (e.g. Hollywood).

I was thinking of doing it using One-To-Many relation where 1 city can have many aliases, and many aliases can map to one city.

When doing a search, I use a join of city and cityAlias table to find the correct city.

Is there a better way to deal with this?

Image

EDIT:
(For anyone who runs into the same problem/requirements and happen to comes to this page)
Please see my answer as well, since I ended up using that, but the marked answer helps you identify unique cities.

  • 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-05-29T09:42:08+00:00Added an answer on May 29, 2026 at 9:42 am

    The only thing I can add to your solution is that you can try first looking for the exact match in the city tables and if there isn’t any, then joining with the alias one. That way you might skip some joins that are quite expensive.

    Another thing to notice is that this double table solution might have trouble with duplicated entries. I’m not talking about same aliases for different cities (this can be checked with a unique column), but aliases matching city names. Example of these “duplicate entries” followed by detailed explanation:

    Cities

    ID | Name
    ---------
    1  | Los Angeles
    2  | New York
    

    Aliases

    ID | CityId | Name
    ------------------
    1  | 1      | LA
    2  | 2      | NY
    3  | 2      | Los Angeles
    

    I know this should not happen… but you know Moore’s laws 🙂 These cross-table-duplicates might give you trouble in a lookup table (I imagine you’re using them as a look up to “guess” what City has actually tried to select the user when he/she wrote “LA”). But if the user wrote “Los Angeles”, you’ll have to decide whether to prioritize the City or the Alias. I know the example I provided is a bit silly but as a non-american citizen I can’t provide better examples. But there are many cities out there with many aliases for each one… I wouldn’t take a chance 🙂

    Checking first the city table will give the city priority over an equaled named alias for other city. Or you can check whether an alias to a city is already present as a city name before inserting it.

    That’s all I can think of 🙂

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

Sidebar

Related Questions

I have a cities model defined which saves the geoname_id and location (as GeoPt)
Given a string location and string file name, is it possible to execute a
I have a coordinate from Core Location and want to calculate the co-ordinate given
I need to figure out whether not a given location is considered urban or
I have a database table of all zipcodes in the US that includes city,state,latitude
I have a page which brings database entries in and displays them, and i
I have MySQL database of areas in a city. The attributes of each area
I have the following: namespace Test { public class Location { public string city
i have a city ALMA but it can be more then 5 in the
I have yet to find a city or location or date, that gives me

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.