I'm working on designing a genealogy rails application, and I'm having some trouble deciding how to design my models. Specifically, I'm working on things that will show up in a timeline. There will be many "things" that show up in the timeline. I've decided I have two types of "things": Event
- A single date, and Period
- a start and end date. Here's a few examples of "things" and which type the fall under:
- Birth [
Event
] - Death [
Event
] - Marriage [
Event
] - Residence [
Period
] - Burial [
Event
] - Cremation [
Event
] - Occupation [
Period
] - Graduation [
Event
] - Family Reunion [
Event
] - Divorce [
Event
] - Adoption [
Event
]
Originally, I was planning on having Event
and Period
be models, in addition to a TimelineObject
model, and then have each of the things in the list above be their own model.
So, the inheritance would be TimelineObject < ActiveRecord::Base
, Event < TimelineObject
, Period < TimelineObject
, and (eg) Birth < Event
and (eg) Residence < Period
That way in rails I could do TimelineObject.all
(or some filter for an individual person) and get all the objects for a timeline.
However, I ran into a problem with how to implement this in rails. I looked into Single Table Inheritance (STI) but that doesn't seem to fit quite right. There will be a few attributes that all of these things share, but many more that they will not, so that would cause many null values in the database. I also thought about maybe using modules somehow for this, but wasn't really sure how.
How would you recommend implementing these "things". Essentially, they're a group of models.
Also, just to be clear, I only need models for these "things". They'll all be associated with a Person model, and they'll be accessed that way. So I don't intend to have controllers or views for any of them.