patternMinor
Local bus schedule structure/design
Viewed 0 times
localdesignbusstructureschedule
Problem
I'm Gergo Nagy, and I'm learning databases. My project is a bus schedule program, in android, but I stucked with the database part.
My program will include 2 main parts:
-If I click on a number of a bus, it shows the whole schedule, and a number, that shows when will the next bus start from the departure point.
-if I click on the address of the bus stop, it shows which buses crosses this stop. But it only shows that buses, which arrives in an hour.
My problem is the many-to-many database, because one bus has a lot of stops, but a stop "has" a lot of buses.
I'll attach a picture, from the schedule, I hope with this it will be easier to understand my question, 'cause my english is really bad, and sorry for that.
I know it's a mess, but with this level of english knowledge, it's my best.
I hope you can help me.
Thank you in advance
My program will include 2 main parts:
-If I click on a number of a bus, it shows the whole schedule, and a number, that shows when will the next bus start from the departure point.
-if I click on the address of the bus stop, it shows which buses crosses this stop. But it only shows that buses, which arrives in an hour.
My problem is the many-to-many database, because one bus has a lot of stops, but a stop "has" a lot of buses.
I'll attach a picture, from the schedule, I hope with this it will be easier to understand my question, 'cause my english is really bad, and sorry for that.
I know it's a mess, but with this level of english knowledge, it's my best.
I hope you can help me.
Thank you in advance
Solution
You have these entities to convert in tables.
I suggest you build the fallowing tables in excel and see if all is there or something missing.
Stations : has name , and id .
Routes : connect stations and defines the bus time from one to another station.
Bus_and_start: when will every buss start and what route. Do you have a list of buses , like buss_long1 , bus_short1 , bus_extralarge4 ? Then split this table in 2 , the bus table and the start table. This would be good if a bus breaks or if you monitor real time if is to slow . Real_time monitoring will bring a list of challenges, not sure if this is part of your project.
To see for a station the next hour bus , you take all the routes that stop in that station and join with all bus_and_start and the route time to the bus start time and here is the list. If you need help , define the tables and I will help with the SQL statement.
I suggest you build the fallowing tables in excel and see if all is there or something missing.
Stations : has name , and id .
Routes : connect stations and defines the bus time from one to another station.
Bus_and_start: when will every buss start and what route. Do you have a list of buses , like buss_long1 , bus_short1 , bus_extralarge4 ? Then split this table in 2 , the bus table and the start table. This would be good if a bus breaks or if you monitor real time if is to slow . Real_time monitoring will bring a list of challenges, not sure if this is part of your project.
To see for a station the next hour bus , you take all the routes that stop in that station and join with all bus_and_start and the route time to the bus start time and here is the list. If you need help , define the tables and I will help with the SQL statement.
Context
StackExchange Database Administrators Q#218329, answer score: 3
Revisions (0)
No revisions yet.