I'm building a rails app that allows athletes to create and manage timesheets for the sport of skeleton. I can't seem to wrap my brain around the correct associations between my models. Here's what I have so far. Athletes have Runs, which are composed of several Splits. Each individual split should be associated with a particular timing Eye on a bobsled/skeleton Track. A collection of runs on a particular date, at a particular track, and on a particular Circuit are organized into a Timesheet. An Athlete creates a timesheet, adds runs and splits to the timesheet, and then has the ability to view and graph the runs on the timesheet. Whew. Here's some code:
class Athlete < ActiveRecord::Base
has_many :runs
has_many :timesheets, :through => :runs
end
class Run < ActiveRecord::Base
belongs_to :athlete
belongs_to :timesheet
has_many :splits
end
class Timesheet < ActiveRecord::Base
has_many :runs
has_many :athletes, :through => :runs
belongs_to :track
belongs_to :circuit
end
class Split < ActiveRecord::Base
belongs_to :run
belongs_to :eye
end
class Track < ActiveRecord::Base
has_many :timesheets
has_many :eyes
end
class Circuit < ActiveRecord::Base
has_many :timesheets
end
class Eye < ActiveRecord::Base
has_many :runs
has_many :splits
belongs_to :track
end
It seems like I make some unnecessary associations here. My biggest frustration has been associating splits with both timing eyes and tracks in the timesheet view table. Table headers are timing eyes that where turned on that day (not every timing eye is turned on every day) while table cells are the actual split times (sometimes, a timing eye misses a particular split for an athlete during a run).
Do you see any place where improvements could be made to these associations?