【发布时间】:2016-01-16 09:21:30
【问题描述】:
我正在为在线多项选择考试开发一个演示应用程序。 当然,每个问题都有多个选项。在问题屏幕上,候选人将选择其中一个选项,提交它并导航到下一个问题。
我已经制定了以下表格结构。
CREATE TABLE users (
username VARCHAR(45) NOT NULL ,
password VARCHAR(45) NOT NULL ,
enabled TINYINT NOT NULL DEFAULT 1 ,
);
CREATE TABLE questions (
id int(10) NOT NULL auto_increment
question varchar(800) NOT NULL,
right_option int(10) NOT NULL references options(id)
);
CREATE TABLE options (
id int(10) NOT NULL auto_increment,
question_id int(10) NOT NULL references questions(id),
option varchar(150) NOT NULL,
);
CREATE TABLE exam_details (
id int(10) NOT NULL,
username varchar(45) NOT NULL references users(username),
date_of_exam date,
exam_result varchar(10) NOT NULL, -- PASS/FAIL
exam_score int(10) NOT NULL, -- e.g. 40
no_of_questions int(10) NOT NULL -- total no. of questions in the test
);
CREATE TABLE user_answers (
id int(10) NOT NULL,
username varchar(45) NOT NULL references users(username),
question_id int(10) NOT NULL references questions(id),
answer int(10) NOT NULL references options(id)
);
数据库将是 MySql。但是请忽略语法,因为我只是想传达这个想法。请建议是否有更好的方法。
补充一下,我将在服务器端使用 spring & hibernate。
【问题讨论】:
-
就个人而言,我会在答案表中标记正确答案
-
请详细说明。您的意思是“问题”表中的“right_option”列应该在“user_answers”表中吗?或者“user_answers”表中的“答案”列不应该引用“选项”表,而只是将答案标识为真/假?
-
第一个 - 但不是 user_answers。只是答案表。
-
与“user_answers”相比,表名“answers”似乎是一个不错的命名选择。谢谢