您需要规范化您的数据库结构。
**Table: users**
id - int
username - varchar
password - varchar
active - enum (y,n)
**Table: questions**
id - int
question - varchar/text
**Table: answers**
id - int
question_id - int (foreign key questions.id)
answer - varchar/text
is_correct_anser - enum (y, n)
**Table: test_master**
id - int
test_name - varchar/text
pass_score - int (minimum score required to pass the test)
**Table: test**
user_id - int (foreign key to users.id)
test_id - int (foreign key to test_master.id)
question_id - int (foreign key to questions.id)
answer_id - int (foreign key to answers.id)
根据以上表格,您可以以规范的方式存储所有需要的信息。请注意,规范化并不总是有帮助,它取决于您的应用程序的要求。一旦测试完成,将总分与 user_id 和 test_id 一起存储在单独的表中也是一个更好的理想选择,因为这将避免连接多个表。