ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

mysql – 如何规范测验应用程序的数据库模式?

2019-08-06 23:14:00  阅读:185  来源: 互联网

标签:mysql database-design schema


参见英文答案 > Data Model for Online Examination – Matching Questions                                    1个
我正在组织一个测验申请. (我把每个测验称为“挑战”)

我有一个“挑战”表和一个“challenge_question”表非常简单.

challenge table:
id
name
num_questions (I want to randomize and only display a certain number of Qs per each challenge)

challenge_question table:
id
challenge_id
question (text of the question)
required (some questions will be required to be displayed per each challenge)
question_type (here I indicate what type of question: Mult. choice, T/F, Ordering, or Fill-in-the-blank)

我在规范化方面遇到问题的地方是问题选项的类型:多项选择,真/假,排序和填空.我想知道,我是否应该针对每种挑战问题选项单独设置表格?或者是否有可能将这些组合成一个…

如果我将所有可能的选项组合到一个表中,它可能看起来像这样

challenge_options table:
id
challenge_question_id
option (text field, can be used for both multiple choice and for fill-in-the-blank style questions)
is_true (boolean field for true/false questions)
is_correct (boolean, used to determine multiple choice answer)
ordering_option_1 
ordering_option_2
ordering_option_3
ordering_option_4 (these ordering fields would store the correct sequence of an ordering style of question)

这真的让我觉得不太理想.实际上,我没有看到ordering_options如何正常工作.难道我不需要让每个人都单独选择吗?当然必须有更好的方法.有任何建议/批评或替代方法吗?

解决方法:

而不是选项我将使用另一个表option_type与PK和名称字段,并在challenge_options中使用fk关系.您可以轻松添加新的挑战.

我不确定我是否会在challenge_options中使用is_true / is_correct.我会使用第二个表,其中包含user_id,challenge_options_id和布尔值正确/ false.

标签:mysql,database-design,schema
来源: https://codeday.me/bug/20190806/1604279.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有