Topic: One model or two?

I'm torn as to whether to store flight details for my app in one model or two. Basically - Departures and Arrivals have the same fields:


For my current purpose though, I'm only interested in arrival date/time for inbound flights, and departure date/time for outbound flights. So should I combine departures and arrivals into one table, and use just one date/time columns for both departure & arrival times, with a flag for whether the flight is an arrival or departure? Or am I better off keeping them separate?

The controllers / views will probably have some logic / presentation in common, bu t not all - at the very least will have to refer to arrivals or departures depending on flight direction, but may also follow a different logic in places, so combining may complicate things in places.

Advice / suggestions appreciated!


PS. Separate Date / Time columns, or one DateTime column?

Re: One model or two?

While I'm not sure what your implementation will be exactly, from what you've given us, they should both be one model.

A flight can be both a departure and arrival, depending on what airport you're at or what time you're looking at. I would put both in a model called Flight and use some methods to get arrivals or departures based on the current/selected airport.

So, for example, I'm a user and want to check status of flights at a specific airport. I would select the airport from a dropdown or similar. That params[:airport] value could be plugged into a method to get arrivals (flights where to_airport == params[:airport]) and departures (flights where from_airport == params[:airport]) and you could order them by arrival/departure time respectively.

Change is a vector. You can have all the change in the world, but if it doesn't go in the right direction, what good is it? |

Re: One model or two?

That's a good point - I hadn't thought of using the from / to airport as context for whether it's an arrival or departure. I'm trying to minimize the input a user is required to provide, so only asking for one time - either arrival time for arrivals, or departure time for departures. I guess I'm still not sure how putting those in the same field will work - need to think about it some more!

For context, this is for coordinating airport transfers at resorts, so isn't concerned with an incoming guests original departure time, or an outgoing guests arrival time at their destination.