Reputation: 856
So I'm using google maps api and I want to store the geocodes temporarily so I'm not making the same call over and over. My question is how should I structure my table for best performance.
Should my api input be like my primary key (ex: '123 fake st, new york, ny 12345')? I'm mainly doing US address, how bad is it to do like a 4 part key(address, city, state, zip)? Other ideas? Thanks!
Upvotes: 0
Views: 114
Reputation: 2287
I would not make your primary key the whole address, considering how many different ways to write an address. Standard (basic) address decomposition is:
Street
Secondary Address Unit (e.g., floor, bldg.)
City
State
Postal Code
Secondary Postal Code (e.g., the 1234 part of 97123-1234)
More detailed decomposition for address matching is to further break down street:
Street Number
Street Name
Street Type (e.g., Ave, Ct)
Street Direction (e.g., NW, SE)
Here's a link to a description on how to do address reduction for matching US mailing addresses that I wrote a couple of years ago: http://www.nwstartups.com/api/doc/middleware.php#streetR
Upvotes: 1