I’ve done some reading on Single Table Inheritance.

I think I need something a little more though.

Classic example.

class Animal < ActiveRecord::Base
// db fields:
name: string
age: int
type: string
breed: string

class Feline < Animal
// db fields:
whisker_count: int

class Canine < Animal
// db fields:
seeing_eye_dog: boolean

So how do Canine and Feline inherit the fields from Animal although
they don’t require each others fields. Does the Animals table just
contain all the fields but value can be null and only returns the
available fields for that Model?


yes, the Animal contains all the field and if you create a Feline
as feline, seeing_eye_dog will be left empty.

Hmmm… This could lead to 60+ blank fields a record (for that
table). Is that bad design, is there a better method I should explore?
Or is this just normal and I should go with it?

I am sorry that i do not have too much ideas about whether STI(Single
Inheritance) are good or not, it depends.

here is article(not mine) you could refer:

I hope that could help you

Thanks for your replies Yong Gu. I believe the article was exactly the
information I was seeking.