It has been some time since my database design classes in my second year at Uni. and I did not do any projects in the interim, so my skills are at best rusty at the moment. I started working on a personal project using a train schedule system and seemed to be stuck in a table design that resembles something like this -
StationTbl ------------ StnName StnCity StnCode - {Primary Key} TrainTbl --------- TrnName TrnNumber - {Primary Key} SourceStn DestStn DaysofWeek TrainHopTbl -------------- TrnNumber - {Primary Key} StationCode - {Primary Key} ArrTime DepTime HopIndex
Most fields are alphanumeric, with the exception of time and HopIndex fields in TrainHopTbl. As you can see, the preliminary design is very rude and far from complete.
Users will be able to find trains based on either the name / number of the train, or by specifying the source and destination station. The first request can be easily solved, but I am having problems writing a request for the second search, where the user gives a pair of src / dest, and the server returns a list of trains that run on this route. This information will be extracted from TrainHopTbl, which contains a list of flights for a particular train, for example:
TrainHopTbl -------------- Num StnCode ArrTime DepTime HopIndex 121 WDC 0900 0910 1 121 BAL 1005 1010 2 121 NYC 1145 - 3
If the user enters WDC / NYC as the src / dest pair, then the request should return train number 121 because it is a valid route.
Any recommendations on pointers / links / books on database design would be helpful. Heck, at that moment even runnable queries or entire re-projects would be useful, as I seem to be stuck in a track that I find difficult to find, and this completely stopped my progress.
source share