Message
From
13/04/2010 03:45:40
 
 
To
13/04/2010 03:40:12
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01459851
Message ID:
01459878
Views:
37
>>So they precalculate Xaxis, Yaxis and Zaxis for each location
>>
>>As to point (2) it's possible if you have a table
>>
>>FK_city1
>>FK_City2
>>Distance
>>
>>
>>The query is then simply:
>>
>>select  * 
>>   from DistanceTable 
>>    where (FK_Where_I_Am in (FK_city1, FK_city2))
>>     and (Distance < = 50.0)
>>
>>
>>
>>The result needs to be joined
>>- with the city table on FK_City2 if (FK_Where_I_Am == FK_city1), and
>>- with  the city table on FK_City1 if (FK_Where_I_Am == FK_city2)
>>
>>
>>Can be done with a union
>>
>>
>>select * 
>>   from DistanceTable
>>    join CityTable on (pk_City = FK_City2)
>>    where ( FK_city1 = FK_Where_I_Am )
>>     and (Distance < = 50.0)
>>union all
>>select * 
>>   from DistanceTable
>>    join CityTable on (pk_City = FK_City1)
>>    where ( FK_city2 = FK_Where_I_Am )
>>     and (Distance < = 50.0)
>>
>>
>>
>>Of course, you never store the distance from a city to itself
>>
>>You need to find a way to store the distance between two cities only once
>
>So, basically, if I have 100 cities, I would have a Distance table with 10000 records minus 100 records. Is that correct?




100 cities become 100 * 100 / 2 records - 100 = 5,000 records - 100 = 4,900 records

ie
The distance from New York to Dallas is the same as the distance from Dallas to New York
Gregory
Previous
Next
Reply
Map
View