Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9114257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:09:35+00:00 2026-06-17T04:09:35+00:00

I have a survey web application. The survey can have a multiple choice question.

  • 0

I have a survey web application. The survey can have a multiple choice question. An answer to a multiple choice question can be dependent on other questions’ answer.

Example:

Question 1 has choices: HP, Acer, Samsung, Lenovo
Question 2 has choices: Android, Ubuntu, iOS, Windows
Question 3 has choices: Ubuntu, OS X, Windows
Question 4 has choices: Adidas, Nike, Puma

Say Question 4 depends on the combination of answers from Questions 1, 2 and 3.

Example 1:

If a person answers: Question 1 = “HP”, Question 2 = “Ubuntu”,
Question 3 = “OS X”; Question 4 is automatically set to “Puma”

Example 2:

If a person answers: Question 1 = “Acer”, Question 2 = “Ubuntu”,
Question 3 = “Ubuntu”; Question 4 is automatically set to “Adidas”

*Both examples have the same logic.

Generally, some survey questions’ answer can be dependent on some other survey questions’ answer.

How do you design/model a database for that purpose?

This is the initial table relationship I’ve created (feel free to modify it):

Users: user_id
Questions: question_id
Choices: choice_id, question_id
Answers: answer_id, user_id, question_id

Additional information:

The admin user interface process I’m thinking of doing is:

1. The admin creates several independent questions (questions which have answers independent of other questions' answer)
2. The admin creates a dependent question, selects one or many questions which he created earlier, selects a combination of answers from those question (just like in examples 1 and 2 above) and then sets an answer for the dependent question based on those combination of answers.
... The admin proceeds creating several more questions.

Edit:

Thanks for your idea @MahmoudGamal. I created something that is based on your design:

 Combinations table
 ID
 question_id # the dependent question's id
 choice_id # the automatic answer based on the combination of other answers

 Answer Combinations table
 ID
 combination_id
 question_id # the question that is depended upon by the dependent question
 choice_id # the choice that will be used for the combination

So I can have several combinations for one question. Example:
If I want Question 4 to accept several combinations. One combination has different answer.

 Answer Combinations table
 ID     combination_id     question_id     choice_id
 1      1                  1               1
 2      1                  2               2
 3      1                  3               3
 4      2                  1               2
 5      2                  2               2
 6      2                  3               1

And the Combinations table would have

 Combinations table
 ID     question_id     choice_id
 1      4               4
 2      4               3

Looks pretty neat to me. What do you think?

PS: Forgive me but I’m new to Stack Overflow and I’m still finding my way around.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:09:36+00:00Added an answer on June 17, 2026 at 4:09 am

    So here is the scenario that I could understood from your question:

    The admin specify a relation between the previous questions’ answers and another question, based on this conditions this question will have an automatically answer based on this relation, and this logic relation is specified manually. So for this, you will need two more tables:

    PreviousQuestionsAnswers:

    • QuestionId,
    • PreviousQuestionId,
    • PreviousAnswerID

    QuestionPreAnswer:

    • QuestionId,
    • AnswerId

    For instance:

    If a person answers: Question 1 = “HP”, Question 2 = “Ubuntu”,
    Question 3 = “OS X”; Question 4 is automatically set to “Puma”

    Then these two tables will have something like:

    PreviousQuestionsAnswers:

    QuestionId PreviousQuestionId PreviousAnswerId
        4              1                 1
        4              2                 2
        4              3                 3
    

    QuestionPreAnswer:

    QuestionId AnswerId
        4         4
    

    Note that: These data are preentered by the admin, so that, from the front end application after the OP that supposed to take that survey, you will match the answeres he entered in the previous questions that supposed to be entered in the Answers that you already have, with the pre defined conditions in the PreviousQuestionsAnswers table, if so then set the question with the choice QuestionPreAnswer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a survey application, where users can create surveys and give choices for
I have a Rails application to do web surveys. It stores answers to multiple-choices
I'm making a survey application. Survey has Questions and Questions have QuestionOption. haveThere is
We have a web application that saves survey data in XML format, rather than
Given a set of questions that have linked survey and category id: > db.questions.find().toArray();
I am developing a very small survey application, likely 3-4 pages web application. so
Recently, I have a developed a very simple web app for a survey. I
I am working on an online survey. Most questions have a scale of 1-5
I have a survey type form, and in a number of the questions, the
I have an asp.net web forms application. In this application, students upload assignments and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.