Hi,
I\'m developing a personals site whereby users can search profiles using zip codes.
One of the most important features of this site will be the ability to search for profiles within a certain mile radius of a zip code.
e.g. I am an x looking for a y within a z mile radius of \'A\'
(where A is the searchers ZIP CODE)
I have a zip code database which consists of 42,000 rows each entry has
CITY,ZIPCODE,AREACODE,STATENAME,LATITUDE,LONGITUDE,COUNTYNAME
Rather than put a huge stress on the server by calculating distances between A and B on the fly, I thought I would create a matrix whereby each unique zip code would be cross-referenced with every other unique zip code. A distance in miles (as the crow flies) would be calculated using PHP (Long,Lat) and inserted for each unique combination of 2 zip codes.
So,
TABLE would resemble something like.
ZIP1,ZIP2,30
ZIP1,ZIP3,47
ZIP1,ZIP4,47
ZIP2,ZIP3,17
ZIP2,ZIP4,50
ZIP3,ZIP4,32
IF I have 42,000 unique zip codes,
1. How many rows will I end up with (approximately)?
2. Is this the best approach?
I envisaged that queries where:
ZIP1=\'A\' AND DISTANCE<z
would work quite well?
Any input greatly appreciated.
PS.
(I\'m in the UK, dont know much about zip codes, are there really 42,000 or do I have too many!?)