sql server - What is the best database table design for point to point distances being stored in SQL Azure -


i intend store list of distances points each other.

so if had 3 points (a-c) like

 | | | distance  |    | b  | 10 miles  |    | c  | 15 miles  | b    | c  | 12 miles 

obviously can infer b = 10 miles since know b = 10 miles. in terms of queries may searching b or b - can't guarantee order of start , end point of journey.

i have 1600 points makes (1600^2 - 1600)/2 = 1.3m possible journeys. best way store data querying either b or b a?

  • should duplicate rows reverse journeys leading 2.5m rows , query on that?
  • or should make composite clustered index on 2 columns , search both b or b knowing @ least 1 exists?
  • or else clever

this on sql azure in case makes difference

one other possible way of doing this,

create column, named 'from_to' below

| | | from_to | distance |    | b  | aba     | 10 miles |    | c  | aca     | 15 miles | b    | c  | bcb     | 12 miles 

now let if want search distance a->b query be,

select distance distance_table from_to '%ab%' 

and distance b->a query be,

select distance distance_table from_to '%ba%' 

this in saving storage space, not sure speed.


Comments