A simple bus reservation system [closed]
Can anybody describe me the logi开发者_StackOverflow社区c that i can use for bus reservation system. I am using MySql free edition. How can i put a facility where closest city name appears automatically to user.
Eg. If user searches bus from cityA to cityB and there are no buses between cityA and cityB. Then automatically, cityC which is closest to cityA and a bus which is there between cityC and cityB should appear?
This sounds like a case where you can use Dijkstra's algorithm to find the most efficient route.
Also, the database should not matter as it should be abstracted away rather than affecting the logic in your code.
Now that you have mentioned lat-long (missing in the question description), see this http://www.scribd.com/doc/2569355/Geo-Distance-Search-with-MySQL
I guess you could have DB table with distances between cities and another with router between cities.
When a user inputs a query for a trip from A->B you can check whether you have A-> in table 2, and if not you select the closest city C for which you have C->B.
精彩评论