I’m about to get started on a Rails app and before getting started I’ve
been
thinking a bit about how I’m going to design the database. The app I’m
building will have a model object to represent a person. The person will
have a core set of attributes that identify them (such as first/last
name).
I also need the capability to associate arbitrary attributes with the
people
within the system. For different sets of people I’ll have different sets
of
attributes which are available. For example for one set of people I
might
have the following:
favorite programming language
favorite technical book
age
And for another set I might have:
age
language
height
weight
There are a few obvious ways to support this in the database. One way
would
be to have a person_attributes table that contains a set of name/value
pairs
associated with a person. Other options, which are less ideal due to the
restrictions they impose on querying, are storing the attributes as an
XMLblob or in some other format but stuffed in a single field.
My question is thisÂ…has anyone had to do something similar, and/or seen
a
plugin that will do something similar to what I’m after?
Cheers,
Steve