【发布时间】:2018-06-29 11:25:13
【问题描述】:
我有一个 SQL 数据库,其中包含 Stores、Users 等表。
Store 和 User 以及其他实体都有一个地址。
我正在考虑为所有地址创建一个地址表:
Users
--------
UserId (PK)
AddressId (FK)
Name
Addresses
--------
AddressID (PK)
CountryID (FK) -> I have a table Countries with all Countries
Street
PostalCode
Locality
Region
Latitude
Longitude
当用户填写个人资料时,我会输入地址。
我想使用 Google Geocoding API 将输入的地址转换为其字段,并将其保存到包括纬度和经度的数据库中。
https://developers.google.com/maps/documentation/geocoding/start
https://developers.google.com/maps/documentation/javascript/geocoding
我有几个问题:
我的地址表方案适合这个吗?
我打算使用 Google 地理编码 API,所以我应该存储 PlaceId 然后 Google 返回我的数据库吗?
我的主要目标是:
将用户输入的地址转换成地址字段并存入数据库;
通过用户在我的数据库中的地址类型的纬度和经度,我将能够按位置搜索它们。 示例:在伦敦地址 20 公里半径范围内获取我的应用程序的用户。
【问题讨论】:
标签: sql-server google-maps database-design geolocation google-geocoder