The basic principle is to store key:value data for an object in a
relational database.
The extra attributes table looks like this:
table attributes
object_klass:string
object_id:int
name:string
value:text
key:value data related to some other model.
Then the object definition would look something like this.
class Car
attr_accessor :props
def initialize
#=> get all schemaless attributes for this object
@props= Attribute.for_object(self)
end
end
There would also be a separate ‘cars’ table to store the essential data
regarding the Car model. The additional attributes are extra things that
might be different from instance to instance.
I’m sure variations of this are commonly used, I was just wandering if
there was an official “design pattern” name for it. Again, this is
referring to storing the data in a relational database.