Mysql database design for bus systems

Source: Internet
Author: User
The mysql database design of the bus system, online and other existing bus lines in a certain area and their corresponding bus lines each station name, for example, 2 Che Qingshan Road -- Bayi Road -- Shanghai Road 3 Che ningnote Road -- Bayi Road -- Shanghai Road... from station name 1 to station name 2, some of them are directly connected by a shuttle bus, and some of them need to be transferred. now I ask: in MYSQL, how should we design the database, if THANKS such as online files are large, you can send me an EMAIL [email & #160 mysql database design for the bus system, online, etc.
The current bus line name and each station name of the corresponding bus line in a region,
For example, 2 Che Qingshan Road-Bayi Road-Shanghai Road
3-Road, Shuyun Road-Bayi Road-Shanghai Road
...
From station name 1 to station name 2, some of them are directly connected by a bus, and some of them need to be transferred,

Question: In MYSQL, how do I design databases? online?
If the THANKS file is large, send me an EMAIL [email protected].

------ Solution --------------------
This should be configured with a 2-dimensional map. I cannot do it myself. Or I understand the simplicity.
Id, website name, and interchange
1 Qingshan Road 2 Road null
2, 8, 1, 2, 3
3. Shanghai Road 2, 3
4. injection path, 3 channels, null
5, 8, 3, 2
6 Shanghai Road 3 Road 2 Road

Qingshan Road> ningzhu Road:
How many vehicles are there on Qingshan Road?
How many route lines are there?
Are they consistent?
Yes :...
No: Which road car can be converted to a stingled road?
However, if there is such a problem, it cannot be found after two or more car transfers.
I can't bear to delete so many words. just mix them up. Cainiao programmers always work and think ....
------ Solution --------------------
I used the keyword "mysql design of bus lines" to find some information.
I have never done it, and it feels a little complicated.
As soon as I saw this problem, I thought of graphs and generalized tables in the data structure. Therefore, I prefer interfaces implemented in other languages. I guess it is.
Good luck!
------ Solution --------------------

The database is like this:

Site table
Number of stations with id (used to calculate the number of stations)

Conversion table
Id: How many route entries can be transferred to the station name (sometimes two-way cars will give different station names in the same location)

In actual calculation, the table should be represented by a graph (not a map, but a graph,
It is the station that each station can reach (the station that can switch to each other as the same point), and then uses the Dijkstra algorithm

However, this is the simplest,
If the bus lines are complex, such as a single road section (the back and forth routes are not completely repeated), more fields are required in the table to differentiate them.
In addition, if you need to calculate the shortest time, it will be more complicated. you need to record the train time ....
Price calculation... if there are different vehicles on the same road (air-conditioned vehicles, normal vehicles )...
And if there is an express train (with fewer stops)... if there are different flights in different time periods, there are also different stops .....
.....
.......
.........
After you have finished the job, you can apply for a project similar to google map ...:)









------ Solution --------------------
Here is an example;
Http://tech.ddvip.com/2009-02/1234417065108419.html
Http://tech.ddvip.com/2009-02/1234598725109794.html main reference.
------ Solution --------------------
Simple storage
Line number
Upstream and Downstream
Names of sites whose names are separated by commas (,) along the line

If you plan to associate with a map in the future, the structure will be slightly more complex.
Line number
Upstream and Downstream
Site No.
Site Name
Site coordinate x
Site coordinate y

Different query algorithms are used for different data organizations.
------ Solution --------------------
1. vehicle number Model departure destination
2. number of upstream and downstream routes
3. serial number fee


The public transit system should be quite complicated. it is best to understand the operation clearly, and then design the table content separately to facilitate future development.
------ Solution --------------------
SQL code
Create table if not exists 'buss' ('id' int (11) not null AUTO_INCREMENT, 'bus' int (11) not null, 'line' varchar (200) not null, primary key ('id') ENGINE = MyISAM default charset = gbk AUTO_INCREMENT = 3; ---- data in the table to be stored 'buss' -- insert into 'buss' ('id ', 'bus', 'line') VALUES (1, 2, 'qingshan Road, Bayi Road, Shanghai'), (2, 3, 'ningnote Road, Bayi Road, Shanghai ');
------ Solution --------------------
I only gave you the basic algorithm for getting through and transferring one time.
This is a second transfer.
You need to take the stations of all the lines starting from the starting point as the starting point, and make a query for them: direct or transfer

The data in your example uses Qingshan Road, Bayi Road, Shanghai Road, and hi-tech as the starting point.
Finally, you will get
Qingshan Road-> hi-tech-> New Road-> New 2 Road

------ Solution --------------------
The landlord apparently did not search for "Dijkstra algorithm"

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.