In continuation of this issue .

There is approximately the following database structure:

The Test table stores the question number and three answers to it.

Table Answer - the correct answer to the question.

The table Test interests actually. It is not expandable, as you can see. To create a new test - you need to create a new table, to add a few more answer choices - you need to create new columns.

How to do right? Thank.

Picture

    2 answers 2

    Here is a good expandable solution:

    [question] id text qtype [answer] id text isright question_id order [user_answer] id user_id question_id answer_id text 

    Sample data:

     [question] id text qtype 1 "Сколько лун на небе?" 1 2 "Столица Франции?" 1 [answer] id text isright question_id order 1 "Одна" 1 1 1 2 "Две" 0 1 2 3 "Три" 0 1 3 4 "Париж" 1 2 1 5 "Лондон" 0 2 2 6 "Нью-Йорк" 0 2 3 [user_answer] id user_id question_id answer_id text 1 1 1 1 "" 2 1 2 2 "" 
    • I agree. I wanted the topstarter to advise referring to the correct answer id from the first table, but even better - toxxxa
    • @pavelip in user_answer If the user enters his own text, and does not select the radiobutton, the text = "answer_user" is received, then the answer_id is empty? - Zhi V
    • Yes you can. There you can write if the user selects multiple answers. If this option is not suitable, then you can make another label for multiple answers. - pavelip

    QUESTION: idQ | TypeQ | TextQ

    TEST: id | idQ | Answer TEST: id | idQ | Answer - tie as many answers to the question

    ANSWER: id | idQ | TrueAnswer ANSWER: id | idQ | TrueAnswer - correct answers are attached to the question id

    • Why do I need a table Test ??? - pavelip