N-ary tree structure modeling in DDB

56 views Asked by At

I have requirement to model hierarchical questionnaire in DDB. The questionnaire will be stored in Dynamo DB, and users will access these questionnaires. Based on the input provided by the user, a score will be calculated.

Questions Details:

  1. Each question can have multiple options.
  2. While the table below does not explicitly depict it, each option may lead to next question, and a single question set can have a variable number of questions.

Question Set and Score calculation details: following table explains the dependency of questions and score calculation mechanism

Q1 Q2 Score
QuestionSet 1 Do you own car?[options: (yes, no)] Yes: When was the last service? [options: (greater than 1 months, greater that 4 months)] No=20, greater than one month=15 greater than four month=5
QuestionSet 2 Do you like travel?[options: (yes, no)] Yes: Where did you travel recently? [multi choice options: 1) New York = 5 , 2) California = 4, 3) Seattle = 7))] no = 20, yes : total sum of second question option

I am planning to structure each question set as n-ary tree. Where node will be connected by question's options value. See following image.

enter image description here

Looking for following details:

  1. How can I model the questions in Dynamo DB.
  2. How can I model the user's response so that score can be calculated.
0

There are 0 answers