Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Subforms or related forms or forms connected through a foreign key ?

  • AlanTygel
  • AlanTygel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago #142560 by AlanTygel
Hi,
Suppose that my problem is a Census, where the questionnaire-unit is a family living in a house, and want to ask several questions such as house size, number of people, income, etc.
I also want to register each member of this family, and some details about them (age, working or studying etc) .

In a database, this would the case of having another table, and connecting family and members through a foreign key. Is is possible to do this in Limesurvey?

I don't want to use an array multi flexible with dynamic row addition [1] for two reasons: (i) I cannot estimate a priori the maximum number of entries, and (ii) I need to have aggregations (e.g., average age of family members), and the array multi flexible would put this value in several columns.

Thanks in advance,
alan

ps: I accept the suggestion of a better topic title in order make this post more findable, even if the answer is negative.

[1] www.limesurvey.org/community-services/fo...le-in-limesurvey-2-5
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 6 months ago #142596 by Joffm
Hi, Alan,
IMHO this is not possible with LS.
If you have access to the database you see that the data are stored in one file.
There are some solutions for your problem: See one of the demos in "LS/docs/demosurveys", esp. manual.limesurvey.org/images/f/f9/Ls2_group_relevance.lss

LS does not support loops. So you have to fake loops though you do not know the number of family members, you surely can limit it to (let's say) 20.
Of course, you have to copy the individual question n times, and set relevance like (numberPersons>1, numberPersons>2, etc.)
And you can aggregate e.g. average of age like {sum(Age1.NAOK,Age2.NAOK,Age3.NAOK,...)/numberPersons}

2. Create a second survey for the member.
You can link the surveys by creating a "speaking" token, like:
Main questionnaire: TOKEN="12345"
Individual questionnaire: TOKEN="12345X01", TOKEN="12345X02",TOKEN="12345X03",TOKEN="12345X04"...

In your analysis software you can easily create this 1:n relation with the foreign key "!12345".

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: AlanTygel
The topic has been locked.
  • AlanTygel
  • AlanTygel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago #142604 by AlanTygel
Great, Joffm.

Thank you so much for the answer. I was already considering using something like vform, which gives me more freedom to model my database. However, my questionnaire is quite big, and in this sense LS helps a lot managing it.

I really appreaciate the second suggestion, because the first one would certainly cause me troubles in the future.
Thanks again,
alan
The topic has been locked.
More
7 years 5 months ago #144250 by alan_tygel
Dear Joffm,
I'm starting to implement my questionnaire, and the second solution you've present looks more sustainable in the long term.
However, as I'm new to lime survey, I'm not very experienced with tokens.

Regarding the Main Questionnaire, when I "Create Dummy Participants", tokens are automatically generated for participants.

My question is: Is there a way I can automatically generate tokens for the Individual questionnaire based on the main questionnaires token (in your example: TOKEN="12345X01", TOKEN="12345X02",TOKEN="12345X03",TOKEN="12345X04") ? Ideally, I imagine a link on the main questionnaire that would open new entries on the individual questionnaire, and these entries would automatically gain related tokens as your proposed.

Is this possible?

all the best,,
alan
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #144259 by Joffm
Hi, alantygel,
to have the token in the desired structure you have to include them in your participant csv-file.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose