How to relate questions to a question

Asked

Viewed 131 times

0

This question is not directly linked to code, but and the basic part of my project, I am currently divided into 2 options (which I will describe in detail below).

Currently the UML is this way, (meets more information in blue and purple; UML

My questionnaire will be basically a tool to which the user can assemble his questionnaire based on the ones that already exist pre-registered in the system and so answer them (I am being very brief about this information),

Now let’s get to my problem:

Each questionnaire has its question, which has its answer option, which finally has the correct answer,

The problem is in defining the correct option, currently I am between these two options:

  1. Enter this information in the question itself (for example: option A, or idOpicao 123)
  2. Or leave the information in the response option itself, (for example: Boolean true for correct option)

Because the doubt between them;

The (1) in a possible correction or exclusion of the response option, it would already mess with the answers already made of the answered ones, because they would be related to the id, and define option A, B or C in a questionnaire with 200 questions I believe this would perform horribly, and I have the impression of being a great gambiarra.

Already the (2) enters again the problem of performance, because to know which is the correct option it would be necessary to always go through the answers to know which is the correct option, a questionnaire with 200 questions and 5 answer options would already have a reasonable weight.

In short my problem is how to define this relationship of question, answer option and correct answer?

In the answer I would like a justification to use the method answered.

  • Yes, I’ve made the correction

3 answers

3


Already the (2) again enters the problem of performance, because to know what the correct option would be to always go through the questions to know the correct option, a questionnaire with 200 questions and 5 response options would already have a reasonable weight.

Hard to imagine this could be heavy.

If it is the apparently most correct and simple to implement option, I would start with it before thinking about performance issues.

If you are very concerned about this, create a separate table with 1-1 relationship between question and answer. This table can store only the references for the correct answers. It would also help you make your system more flexible if there is more than one correct answer to the question, which is not possible in option 1.

  • I’m thinking of keeping it that way, and in the user’s reset table set a column true/false correct, so I wouldn’t even need to go through the reference column,

2

Another option would be to make an associative table between User_questions and Question options, indicating which or which are the correct answers(ids) or which are the correct values.

This way it would be possible to even keep a history of which answers have already been considered correct.

I think performance is something you should not worry about at the moment, regardless of the way you choose to solve your problem. Because all solutions will perform very closely. What you should focus on is functionality, problem solving and the practicality of development.

0

Only indicate through an attribute of the alternatives whether or not it is the correct answer. I didn’t understand what you meant by :

"to know the correct option it would be necessary to always go through the questions to know which is the correct option..."

I don’t know if you are referring to the application part or the database, but if it is in the application you just "take" the alternative chosen by the user and check whether it is the correct one or not, without going through all the questions/alternatives.

  • In case you did not specify where I would define this attribute, in the answer or in the question.

  • I specified yes when I said : "indicate by means of an attribute of the alternatives whether or not it is the correct answer"

  • Using this method, I would get into the update / deletion / problem of people who have already answered the question in question (if it is the correct option) which alternative you would give me for it?

  • 2

    I don’t see any other alternative, because I just can’t identify a real "problem" that I’m facing. I don’t know how the rules work for your system, but the truth is that no matter which method you choose at some point updates will be made, keep in mind that the update/deletion will only be done as needed, so don’t worry about performance, If necessary, it will have to be done! There’s no other way.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.