Mysql数据库设计在线考试

时间:2021-06-14 12:45:30

Im creating an optimized database for online exam module.

我为在线考试模块创建了一个优化的数据库。

I have two choices:

我有两个选择:

  • Schema with which Im storing the question, options and answer in same row.

    用于将问题,选项和答案存储在同一行中的模式。

    Table: questions Col: q_id, question, opt1, opt2, opt3, opt4, opt5, ans

    表:问题Col:q_id,question,opt1,opt2,opt3,opt4,opt5,ans

  • Schema with which Im having 3 different tabled for each operation.

    每个操作我有3个不同表格的模式。

    Table: questions Col: q_id, question

    表:问题Col:q_id,问题

    Table: options Col: q_id, opt_id, option

    表:选项Col:q_id,opt_id,option

    Table answers Col: q_id, ans

    表答案Col:q_id,ans

5 个解决方案

#1


0  

Schema 2 is more along the lines of what you should be aiming for.

模式2更符合您应该瞄准的目标。

#2


0  

There could be a 3rd option:

可能有第三种选择:

q_id | question | options | answer

where the option column is of type text and stores a serialized array or json.

其中option列的类型为text,并存储序列化数组或json。

For the 2 options you provided: the 2nd one world be the weapon of choice

对于您提供的2个选项:第二个世界是首选武器

#3


0  

I would use schema 2, as it allows you to add an arbitrary amount of answers.

我会使用模式2,因为它允许您添加任意数量的答案。

You could however incorporate the answers table in the options table.

但是,您可以将答案表合并到选项表中。

q_id | opt_id | option | correct

In this way you can also have multiple correct answers per question.

通过这种方式,每个问题也可以有多个正确的答案。

#4


0  

Schema 2 would be the better option if you want to stay flexible in your exam options.

如果您希望在考试选项中保持灵活性,则架构2将是更好的选择。

However, if you are sure you can set a fixed amount of questions every time, you might want to consider putting table "questions" and "options" into one and just having the answers vary for each user.

但是,如果您确定每次都可以设置固定数量的问题,则可能需要考虑将表“问题”和“选项”放在一个中,并且每个用户的答案各不相同。

#5


0  

If there is a fixed number of answers schema 1 would be better

如果有一个固定数量的答案,架构1会更好

but if the question may have any number of answers this would be better

但如果问题可能有任何数量的答案,那就更好了

question_id,question,answer_id_of_the_solution

answer_id,question_id,answer

#1


0  

Schema 2 is more along the lines of what you should be aiming for.

模式2更符合您应该瞄准的目标。

#2


0  

There could be a 3rd option:

可能有第三种选择:

q_id | question | options | answer

where the option column is of type text and stores a serialized array or json.

其中option列的类型为text,并存储序列化数组或json。

For the 2 options you provided: the 2nd one world be the weapon of choice

对于您提供的2个选项:第二个世界是首选武器

#3


0  

I would use schema 2, as it allows you to add an arbitrary amount of answers.

我会使用模式2,因为它允许您添加任意数量的答案。

You could however incorporate the answers table in the options table.

但是,您可以将答案表合并到选项表中。

q_id | opt_id | option | correct

In this way you can also have multiple correct answers per question.

通过这种方式,每个问题也可以有多个正确的答案。

#4


0  

Schema 2 would be the better option if you want to stay flexible in your exam options.

如果您希望在考试选项中保持灵活性,则架构2将是更好的选择。

However, if you are sure you can set a fixed amount of questions every time, you might want to consider putting table "questions" and "options" into one and just having the answers vary for each user.

但是,如果您确定每次都可以设置固定数量的问题,则可能需要考虑将表“问题”和“选项”放在一个中,并且每个用户的答案各不相同。

#5


0  

If there is a fixed number of answers schema 1 would be better

如果有一个固定数量的答案,架构1会更好

but if the question may have any number of answers this would be better

但如果问题可能有任何数量的答案,那就更好了

question_id,question,answer_id_of_the_solution

answer_id,question_id,answer