Home >Backend Development >PHP Tutorial >A question about real-time passenger flow, how to design the database and how to implement this function?
1. Requirements: I now need to make a bus passenger flow display, using different displays to display the bus passenger flow, similar to the real-time traffic conditions on the map. All statuses are manually set in the background.
2. There is a line 1 with stations A, B, C, D, E, F, G, H. You can travel A->H, or you can travel H->A. Set A->B is state 1, B->C is state 2, C->H state 3.
The displayed state is:
A--state 1-->B--state 2-->C-state 3 -->H
If B-E is set to state 4, the displayed state is:
A--state 1-->B--state 4-->E--state 3-->H
The same goes for traveling in the opposite direction.
Now I have no idea how to do this, including how to design the database. I hope you can give me some ideas, thank you
1. Requirements: I now need to make a bus passenger flow display, using different displays to display the bus passenger flow, similar to the real-time traffic conditions on the map. All statuses are manually set in the background.
2. There is a line 1 with stations A, B, C, D, E, F, G, H. You can travel A->H, or you can travel H->A. Set A->B is state 1, B->C is state 2, C->H state 3.
The displayed state is:
A--state 1-->B--state 2-->C-state 3 -->H
If B-E is set to state 4, the displayed state is:
A--state 1-->B--state 4-->E--state 3-->H
The same goes for traveling in the opposite direction.
Now I have no idea how to do this, including how to design the database. I hope you can give me some ideas, thank you
Let me give you a quick tip - when saving the database, divide it into small sections according to the minimum granularity:
<code> | begin | end | status | | A | B | 1 | | B | C | 2 | | C | D | 3 | | ... | ... | ... | | D | C | 1 | | C | B | 2 | | B | A | 3 | </code>