Design of background database for bus route query system--query algorithm

Source: Internet
Author: User

1. How the bus route information is stored in the database

Obviously, if the simple use of table Bus_route in the database (route name, route through the site, cost) to save the bus route information, it is difficult to use the query statement to achieve the bus line query, therefore, should be processed on the line of information and then saved to the database, The method used by the author is to store bus routes using the site-route relationship Table Stop_route (site, Route name, site in the route), for example, if the following 3 routes

R1:S1->S2->S3->S4->S5
r2:s6->s7->s2->s8
R3:S8->S9->S10

Then the corresponding site-route relationship Table Stop_route is

Stop Route Position
S1 R1 1
S2 R1 2
S3 R1 3
S4 R1 4
S5 R1 5
S6 R2 1
S7 R2 2
S2 R2 3
S8 R2 4
S8 R3 1
S9 R3 2
S10 R3 3

Note: Stop is the site name, route is the route name, position is the location of the site in the route

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.