Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:27:14+00:00 2026-06-17T04:27:14+00:00

I have a Flight class which represents a flight in a pilot’s logbook. It

  • 0

I have a Flight class which represents a flight in a pilot’s logbook. It is composed of the following attributes:

  • duration
  • landings
  • remarks

It also has an airport and time of both departure and arrival, which are related to my question.

I have though about modeling the the arrival and the departure as a Movement, which would be composed of the airport and the time. I would then derive a Departure and an Arrival class from the Movement, and have the Flight reference one of both.

Then I bumped into a discussion on Ruby’s TrueClass and FalseClass (Why does Ruby have TrueClass and FalseClass instead of a single Boolean class?). The gist of it was that Ruby does not model true and false as a Boolean because they do not share any behavior and I believe the same goes for an arrival and a departure. They are exactly opposite even though they do share data.

Another option is that I simply embed the arrival and departure’s data fields in the Flight. I find this awkward because that would mean that if you would traverse from the Airport model to the departures and arrivals (has_many :departures, has_many :arrivals) would yield a Flight model.

A third option I explored is creating separate Departure and Arrival models without inheriting from a Movement. However, since a Flight is required to have both and arrival and a departure, which are required to reference flight, we have created a nasty circular reference (which also plagues the first option, by the way).

How would I best model this relationship? Are there any alternatives I have failed to consider?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:27:15+00:00Added an answer on June 17, 2026 at 4:27 am

    Speaking from a UI developer perspective, this is what I’d start with.

    I suspect you will often do two things –

    1) display the flight in a list and include the departure and arrival information in the list item
    2) sort the list by time of departure and arrival

    These will be easier/faster to do if the attributes are on the flight. You’ll avoid the joins. Since the information is required, no need to ‘has_one’. You can always move them later in a migration if you need to. Keep it simpler until the use cases come up.

    I think it will also be easier for you to make a has_many :arrivals (which are of type Flight) on the airport by simply looking at the Flight’s arrival airport id.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI, I have the following model: @Entity class Flight{ private Airport airportFrom; private Airport
I have a domain class called Flight that represents a flight that has been
I have the following pseudo-SQL schema: table flight id int primary key date timestamp
have written this little class, which generates a UUID every time an object of
I have a class called Flight The Flight class when instantiated, instantiates another class
I have a class Flight, and I'm trying initialize it, but I have a
I have a mysql table which has data from all flight bookings on my
I have 2 classes: public class FlightCostInfo : BaseEntity<Guid> { public Flight FlightInfo {
I am making a flight simulator game in XNA. I also have several blimps(Airships)
I have two classes, as follows: public class Route { public ObservableCollection<Flight> Flights =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.