I have a model, let’s call it an Assessments model. This model
describes a collection of questions I’m developing to profile a user.
So the first one is maybe a travel assessment. It consists of a few
questions related to travel. Another assessment may be a sports
assessment. This will find out what types of sports/recreational
activities you like through a variety of questions.
Now each assessment has_many questions. For travel it may be, do you
like warm or cold climates? Each question has_many Answer Choices,
which may be yes, no, maybe, sometimes, or a variety of other
options. And then each question will also has_one answer, per user,
that has a FK to the Users table and Question Table.
This should give you an idea of what an assessment is. Now, each
assessment has a profile. So the travel assessment will allow the
user to create a travel profile. And the sports assessment will allow
a sports profile (think online profile or something with descriptions,
interests, etc).
My question is: How can I model these profiles? They can’t really
use STI because while there are a few overlapping similarities in the
profiles, I may eventually have 30 assessments and 20 different fields
per profile - so over 600 fields in that one table (with STI).
Polymorphism doesn’t work because I don’t have enough duplication
between the profiles. So what can I use? I’ve thought about creating
a different model for each profile. Like a TravelProfiles model and a
SportsProfiles model. But this seems like a lot of programming work
per new assessment added. Then I thought about adding a ProfileFields
model that will allow you to add a new row for a field and add an
assessment type FK to that table. The only problem is, how do I deal
with different data types? Like if one field is a multiple choice,
where should I store the multiple choices? Or even if it’s a yes/no
question, how do I store that in the database and make use of the data
in the view?
Ugh…sorry, long question! Thanks for any insight!