gwhite:

I'd start simple by having a table of "score modifiers" for questions based on demographic group type. Then for a respondent, sort the questions by score and pick your questions from near the front of the list.

create table questions ( QID number constraint questions_pk primary key, question varchar2(1000) ); insert into questions (qid, question) values (1, 'Duz ya likes teh exersize equips?'); insert into questions (qid, question) values (2, 'Would you like fast relief from muscle aches?'); create table group_attributes ( GAID number constraint groups_attributes_pk primary key, gr_attr varchar2(30) ); insert into group_attributes (gaid, gr_attr) values (1, 'Male'); insert into group_attributes (gaid, gr_attr) values (2, 'Female'); insert into group_attributes (gaid, gr_attr) values (3, 'Under 15'); insert into group_attributes (gaid, gr_attr) values (4, '16-20'); insert into group_attributes (gaid, gr_attr) values (5, '20-35'); insert into group_attributes (gaid, gr_attr) values (6, '35-65'); create table question_bonuses ( QID number constraint question_bonuses_FK1 references questions(QID), GAID number constraint question_bonuses_FK2 references group_attributes(GAID), bonus number ); create index question_bonuses_pk on question_bonuses(QID,GAID); -- people from 16-35 are more interested in exercise equip insert into question_bonuses (qid, gaid, bonus) values (1, 4, .2); insert into question_bonuses (qid, gaid, bonus) values (1, 5, .2); -- A slight preference for males? insert into question_bonuses (qid, gaid, bonus) values (1, 1, .05); -- Older people are much less interested... insert into question_bonuses (qid, gaid, bonus) values (1, 6, -.5); -- But pain relief is more welcome in this case... insert into question_bonuses (qid, gaid, bonus) values (2, 6, .3);

Then when you have a respondent, add all the question bonuses and sort them by score and you can choose from the better questions.

select qid, question, ( select sum(bonus) from question_bonuses qb join group_attributes ga on ga.gaid=qb.gaid where qb.qid = q.qid and ga.ga_attr in (...respondent attribs...) ) as score from questions q order by score descending

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: OT: predicting related content by roboticus
in thread OT: predicting related content by gwhite

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.