N
N
NickOver2021-01-22 16:32:57
MySQL
NickOver, 2021-01-22 16:32:57

What is the correct way to create a MySQL database view with multiple sub-columns?

The bottom line is to make a database in MySQL with data on bus numbers, stations, arrival and departure times.
I can't figure out how to correctly present this database, so that later I can easily extract the necessary data using php.
For example, a person chose the departure time and departure station - he was offered options for buses with the nearest time, or he chose the bus number and the entire schedule was displayed.
This is how the data table looks like in excel

spoiler
600ad14da6ed3986190448.png

This is how i tried to make the db
spoiler
600ad254d3dd6447918107.png

But soon I realized that I would not be able to unload and select individual route numbers, I could only work in fact with station data and times.
Request type
SELECT `bus`, `stations`, `time_departure` FROM `table_name` WHERE (`time_departure` BETWEEN '00:06' AND '00:35') AND (`stations` LIKE 'Фрязики')

will be impossible.

I ask you to suggest the right idea or where you can see ready-made similar examples.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2021-01-22
@NickOver

store time in the time format , and not some obscure
UPD bullshit:
firstly, put the route numbers in a separate table, and secondly, put the stops in a separate table. And then the table will look like this:
id | route_id | station_id | arrival_time | departure_time

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question