Mar 26 2008

a computational conundrum for you programmer-types…

Category: UncategorizedCharlene @ 3:13 pm

So…now that my training db project has sprouted a zillion heads hydra-like, I’ve hit a difficult patch…

I’m setting up a report/form that will calculate mileage reimbursement for those who travel to events. Assuming I can complete the sparse matrix of these things, what do you all think is the best way to store and manipulate/call said information? I’m using MySQL and PHP, and there are something like 200 combinations.

My first thought was to store it in a table, with three fields: loc1 and loc2 for uids of locations (which are also stored elsewhere in the db), and dist for the distance in kilometers between the two. To minimize storage and update headaches, I could in theory use a query like this to get the distance:

SELECT dist from disttable where ((loc1 = x AND loc2 = y) OR (loc1 = y AND loc2 = x)) LIMIT 1

What do you all think? Is there a better way?

Tags:

Leave a Reply