I'm working on a rails app (if that's relevant) and I'm needing to have users create a list of event at businesses all over the world and I'm wondering what the best way to structure it would be. I would like for the user to select a country, then a state inside of that, and then a city, and then a business where each selection scopes the options for the next. If a business doesn't exist in the database, I want to allow the user to type in their option and then that will be a possible selection for the next user who goes through this process. What's the best way to approach this?
我正在开发一个rails应用程序(如果这是相关的),我需要让用户在世界各地的企业创建一个事件列表,我想知道最好的结构方式是什么。我想让用户选择一个国家,然后选择一个国家,然后是一个城市,然后是一个企业,其中每个选择范围为下一个选项。如果数据库中不存在某个业务,我希望允许用户键入他们的选项,然后这将是下一个完成此过程的用户的可能选择。什么是最好的方法来解决这个问题?
I'm assuming I need to model this as country has many states has many cities has many businesses.. please let me know if this is the correct structure for this.
我假设我需要对此进行建模,因为国家有很多州有许多城市有很多业务..请告诉我这是否是正确的结构。
Also, are there common databases of countries/states/cities that I should use? Are there services that I should use? Is there a benefit to one over the other, or is there a completely different, better approach? I know this is nothing new, but I'm not sure of the best way to approach this, so I'm looking for some direction..
此外,是否有我应该使用的国家/州/城市的共同数据库?我应该使用哪些服务?一个人对另一个人有好处,还是有一个完全不同的,更好的方法?我知道这不是什么新鲜事,但我不确定最好的方法,所以我正在寻找一些方向..
Let me know what you all have learned from experience.
让我知道你们从经验中学到了什么。
Thanks!
2 个解决方案
#1
1
You can use postal codes for general navigation. Services like Google Maps can provide the rest (state, country or whatever).
您可以使用邮政编码进行常规导航。 Google地图等服务可以提供其他服务(州,国家或其他)。
Just my two cents...
只是我的两分钱......
#2
1
Given that all of this varies greatly depending on country (including the actual address format), I would opt for an approach like this:
鉴于所有这些因国家(包括实际地址格式)而有很大差异,我会选择这样的方法:
- Let the user pick a business/latlong pair.
- Try to reverse geocode said business or location.
- Allow the user to make corrections to the geocoded info.
让用户选择业务/ latlong对。
尝试反转地理编码所说的业务或位置。
允许用户更正地理编码信息。
Don't try to impose a schema on something that is basically impossible to standardize. Instead let the users — with as much assistance as possible — take care of the hard part, they have the knowledge about their country that you lack.
不要试图在基本上不可能标准化的东西上强加模式。相反,让用户 - 尽可能多的帮助 - 照顾困难的部分,他们拥有你缺乏的国家知识。
#1
1
You can use postal codes for general navigation. Services like Google Maps can provide the rest (state, country or whatever).
您可以使用邮政编码进行常规导航。 Google地图等服务可以提供其他服务(州,国家或其他)。
Just my two cents...
只是我的两分钱......
#2
1
Given that all of this varies greatly depending on country (including the actual address format), I would opt for an approach like this:
鉴于所有这些因国家(包括实际地址格式)而有很大差异,我会选择这样的方法:
- Let the user pick a business/latlong pair.
- Try to reverse geocode said business or location.
- Allow the user to make corrections to the geocoded info.
让用户选择业务/ latlong对。
尝试反转地理编码所说的业务或位置。
允许用户更正地理编码信息。
Don't try to impose a schema on something that is basically impossible to standardize. Instead let the users — with as much assistance as possible — take care of the hard part, they have the knowledge about their country that you lack.
不要试图在基本上不可能标准化的东西上强加模式。相反,让用户 - 尽可能多的帮助 - 照顾困难的部分,他们拥有你缺乏的国家知识。