- #1
- 2,136
- 2,711
I have a database of bus routes in MySQL. Each table has three columns:
and another table,
So, if I want to go from region2 to region4, I have two bus routes in my database.
Consider the case where my database contains a large number of similar tables. I want to filter out programmatically which routes go through region2 and region4. How can I do this?
I am completely new to MySQL and am open to all suggestions. If there is a better way to format my tables so as to aid this type of search, please suggest so. My ultimate aim is to implement this in an application where the user will enter the starting point and destination, and the program will search through the database for all bus routes covering these two places and display them. Then the user will choose a route and the fare will be displayed.
location1
, location2
and fare
for going from location1 to location2. Consider one table of this database, route_a
which goes via region1 → region2→ region3 → region4:and another table,
route_b
which goes via region5 → region2 → region6 → region4 → region7:So, if I want to go from region2 to region4, I have two bus routes in my database.
Consider the case where my database contains a large number of similar tables. I want to filter out programmatically which routes go through region2 and region4. How can I do this?
I am completely new to MySQL and am open to all suggestions. If there is a better way to format my tables so as to aid this type of search, please suggest so. My ultimate aim is to implement this in an application where the user will enter the starting point and destination, and the program will search through the database for all bus routes covering these two places and display them. Then the user will choose a route and the fare will be displayed.