Hello! I'm trying to create a website where you can add and take multiple question test, 1 question, 4 answers. I have another page called QuestionAnswerOverview where all the questions and answers are listed. This is my entity diagram.

This is my preparation for the page where questions and answers are added. 

I want the data to be something similar to the example below. Is it possible? Or does it need to be changed? I'm not so good in Entity and Attributes setup, but I'm learning. 

Each answer has a boolean value IsCorrect to determine if the answer is correct.

Both the questions and answers are added without problem. In the Save Action that is a button inside AddQuestionAnswer-page, CreateOrUpdateAnswer and CreateOrUpdateQuestion

But when I want to view the questions and answers in the QuestionsAnswerOverview-page the answers will not be show next to the questions. 

How can I present the data as shown in the Excel or something similar? Without the Question.Id of course. 

Are the entities and attributes correct? 

Hi Felipe

Your answer entity's structure looks a little confusing to me.

How can you determine which answer is correct?

Best Regards

Tom Zhao wrote:

Hi Felipe

Your answer entity's structure looks a little confusing to me.

How can you determine which answer is correct?

Best Regards

 

I want to add a boolean value TRUE (isCorrect) to the correct answer, as shown in Excel.
The Idea was to connect the Answer.Id, which hold all the four answers, with Question.Id, but I'm not sure ifthis is the correct way to do it, or if there is a better way.


Or should I create four Entities, Answer1 - Answer2 - Answer3 - Answer4, with same attributes: Answer(text) and IsCorrect(boolean) to each of them?

Hi Felipe ,

Remove AnswerId from Question Entity and add Question Id in Answer Entity.

And use join  and you are able to get data as you want.


Regards

Rahul Sahu

Tom Zhao wrote:

Hi Felipe

Your answer entity's structure looks a little confusing to me.

How can you determine which answer is correct?

Best Regards

 I think your Answer entity should look like below. The Sequence is an integer type attribute. The value should be 1 to 4.

 

Rahul Sahu wrote:

Hi Felipe ,

Remove AnswerId from Question Entity and add Question Id in Answer Entity.

And use join with or without and you are able to get data as you want.


Regards

Rahul Sahu

What's the reason that you add Question.Id in Answer instead? 

I changed them, but for some reason it doesn't show the answers.

 

I just saw that the Answer Entity has Question.Id as 0 for all the rows. I thought the ID was. Maybe thats the reason it wouldn't show? 

Tom Zhao wrote:

Tom Zhao wrote:

Hi Felipe

Your answer entity's structure looks a little confusing to me.

How can you determine which answer is correct?

Best Regards

 I think your Answer entity should look like below. The Sequence is an integer type attribute. The value should be 1 to 4.

 

 

I see. So instead of having four text answers the Sequence determine the four questions for the Question.Id?

How would it be with the four answer inputs being pushed to DB at the same time? 

Hi Felipe,

As per your mentioned requirement, I would have thought of Data model as mentioned below

Hope this helps!


Regards,

Benjith Sam

Felipe Sepulveda wrote:

Tom Zhao wrote:

Tom Zhao wrote:

Hi Felipe

Your answer entity's structure looks a little confusing to me.

How can you determine which answer is correct?

Best Regards

 I think your Answer entity should look like below. The Sequence is an integer type attribute. The value should be 1 to 4.

 

 

I see. So instead of having four text answers the Sequence determine the four questions for the Question.Id?

How would it be with the four answer inputs being pushed to DB at the same time? 

 Hello Felipe,

Just to clear your doubt about this, In the above suggestion, you are probably making 1-Many relation between your Question - Answer entity, By adding QuestionId to Answer entity, you can achieve it in below manner :

suppose your QuestionId is 101, and Answer Ids being 201,202,203,204... so data can be stored like :

101 - 201

101 - 202

101 - 203

101 - 204 .. so on

Now by using 101, you can get all the answers from answer entity.


Kindly refer below documentation for better understanding of Entity Relationship :

https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Data_Modeling/Entity_Relationships

Hope it helps!

Regards,

Sanjay