简体   繁体   English

测验分层数据的数据库结构?

[英]Database structure for quiz hierarchical data?

I'm doing a personal project where I have a quiz with a number of boolean questions. 我正在做一个个人项目,其中有一些布尔问题的测验。 Each question will have a two answer choices "true" and "false". 每个问题都有两个答案选项“真”和“假”。 Based on the selected answer, a new question will be asked with the similar pattern and based on that an another question. 根据选择的答案,将以类似的模式询问新问题,并根据该问题回答另一个问题。 Any question may have any or no number of sub-questions. 任何问题都可以包含任何子问题,也可以不包含任何子问题。

The last questions in the tree (E, D) and questions with no sub-questions (F) will also store the correct answer from either "true" or "false". 树中的最后一个问题(E,D)和不包含子问题的问题(F)也将存储来自“ true”或“ false”的正确答案。

The alphabets A,B,C,D,E,F are questions. 字母A,B,C,D,E,F是问题。 A quiz can have any number of master questions (like A), sub-questions like (like B,C,D,E) and individual questions (like F). 测验可以包含任意数量的主要问题(例如A),子问题(例如B,C,D,E)和单个问题(例如F)。

Kindly help me design a simple database schema for for this kind of quiz. 请帮助我为这种测验设计一个简单的数据库架构。 I'm open to both relational (mysql) and document (mongodb) databases. 我对关系数据库(mysql)和文档数据库(mongodb)都开放。

概念图

How about (assuming relational) questions, answers and a link from answers to the following question. (假设是相关的)问题,答案以及答案与以下问题的链接如何?

Questions
---------
Question_Id
Question details

Answers
-------
Question_Id
Correct FLAG
Next_Question (fk to Question_Id)

when next question is null you can assume the quiz is over. 当下一个问题为空时,您可以假定测验已经结束。

I don't think noSql will naturally lend itself to this sort of problem. 我认为noSql不会自然而然地解决这种问题。 I'd stick with relational unless you have a specific need for nosql or you could consider using a graph database. 我会坚持使用关系型,除非您对nosql有特定的需求,或者可以考虑使用图形数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM