Storing dates i Train schedule MYSQL

Posted by App_beginner on Stack Overflow See other posts from Stack Overflow or by App_beginner
Published on 2010-04-19T16:00:47Z Indexed on 2010/04/19 16:03 UTC
Read the original article Hit count: 149

Hi

I have created a train schedule database in MYSQL. There are several thousand routes for each day. But with a few exceptions most of the routes are similar for every working day, but differ on weekends.

At this time I basically update my SQL tables at midnight each day, to get the departures for the next 24 hours. This is however very inconvenient. So I need a way to store dates in my tables so I don't have to do this every day.

I tried to create a separate table where I stored dates for each routenumber (routenumbers are resetted each day), but this made my query so slow that it was impossible to use. Does this mean I would have to store my departure and arrival times as datetimes? In that case the main table containing routes would have several million entries.

Or is there another way?

My routetable looks like this:

StnCode (referenced in seperate Station table)
DepTime
ArrTime
Routenumber
legNumber

© Stack Overflow or respective owner

Related posts about mysql

Related posts about schedule