I am preparing to collect large amounts of information about trains in my country. Each train in my country has a number. I've already collected all of these numbers. There are about 4000 of them.

Now, for each train, I want to collect information about its route and its delays, every day.

Another issue is the following: I have to make a distinction between 2 periods. The period before a new train system was introduced and the period after the new system was introduced.

I used MongoDB for all the stations and for the train-numbers, so I would also like to use MongoDB for the daily routes. My initial thought was the following:

I created a database for the old system (lets call it OldDB) and a database for the new system (lets call it NewDB). In these 2 databases, I created a collection for each train-number in the following form: trainxxx with xxx being the train-number. This results in approx. 4000 collections.

Example: Lets say the date is d and this is before the new system. The train-number is x. The information collected about train x on date d will go in OldDB in collection trainx

Is this a good way to store this? Is there a smarter way to handle this?

  • Have you considered using just a single central collection for trains, and using nested documents to store data about each train's routes? Having multiple collections can make certain queries impossible (or at least very complicated to pull off). Moreover, for the whole old vs. new system, I'd simply tag the trains with something like a systemNumber field to indicate which particular train system that entry belongs to (the old one or the new one). – Andrei Bârsan Feb 19 '15 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.