Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best approach to storing location information in a database?

The location data is essentially in a tree structure. So when you ask someone for their address you would like to know what Area/Suburb, City/Town, State/Province and Country that they live in.

This data will hopefully be set up only once and need very little modification. Most E-commerce sites and a lot of others would need to store this type of information but I am struggling to find much about it. Maybe because I am not searching for the right term but I thought it would be a common problem that has already been solved.

This leads to another question. Where could I get my hands on this type of information like what areas belong in which city, which cities belong in which states and which states belong in which countries?

EDIT: To make things more complicated I would like to be able to provide a generic sort of solution because for example some countries don't use zip codes, they use postal codes, it is sort of the same thing but not quite. My big desire is to have Area/Suburb -> City/Town -> Region/Province/State -> Country. I might be attempting the impossible.

EDIT2: Sorry I might not have been clear enough but I don't need zip codes. Just the Suburb/Area NAME -> City........

like image 290
uriDium Avatar asked Nov 15 '22 15:11

uriDium


1 Answers

If you're wanting to obtain US zips information have a look at Tiger. It's information from a US census and will provide you with all the data. However, the caveat is that the information isn't easy to abstract, so it will take some time.

like image 199
Gavin Miller Avatar answered Jan 25 '23 22:01

Gavin Miller