我正在处理这个面试候选人的小项目,并给他们的答案打分。
例如:
问题(A)带有类似的答案:
a1 - Alternative 01 (02 points)
a2 - Alternative 02 (05 points)
a3 - Alternative 03 (00 points)
然后我创建的数据结构如下:
访问此数据模式here
我想做什么?
[使用PHP
创建一个接收类似JSON的API:
"query":{
"candidate":"JOHN",
"answer":"a1, a2"
"question_id": 1
}
然后将INSERT
数据发送到候选表
然后需要TABLE
至JOIN
已回答的问题并求职者选择的总和得分
我正在尝试做,但是没有得到结果。
感谢您阅读到现在为止。
创建表的SQL代码:
CREATE TABLE `Candidates` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`name` text,
`age` int,
`birthday` date
);
CREATE TABLE `Candidate_Answers` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`Candidate_id` int,
`Question_id` int,
`Interview_id` int,
`Candidate_Answer` text
);
CREATE TABLE `Candidate_Score` (
`Candidate_Answer_id` int PRIMARY KEY,
`Answers_Score_id` int,
`Candidate_Score` int
);
CREATE TABLE `Questions` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`Question_Type_id` int
);
CREATE TABLE `Type_of_Question` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`Type` varchar(1)
);
CREATE TABLE `Interview` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`date` date
);
CREATE TABLE `Questions_in_Interview` (
`Interview_id` int,
`Question_id` int,
PRIMARY KEY (`Interview_id`, `Question_id`)
);
CREATE TABLE `Answers_Score` (
`id` int PRIMARY KEY,
`Question_id` int,
`Score` int
);
ALTER TABLE `Candidate_Answers` ADD FOREIGN KEY (`Candidate_id`) REFERENCES `Candidates` (`id`);
ALTER TABLE `Candidate_Answers` ADD FOREIGN KEY (`Interview_id`) REFERENCES `Questions_in_Interview` (`Interview_id`);
ALTER TABLE `Candidate_Score` ADD FOREIGN KEY (`Candidate_Answer_id`) REFERENCES `Candidate_Answers` (`id`);
ALTER TABLE `Candidate_Score` ADD FOREIGN KEY (`Answers_Score_id`) REFERENCES `Answers_Score` (`id`);
ALTER TABLE `Answers_Score` ADD FOREIGN KEY (`Question_id`) REFERENCES `Questions` (`id`);
ALTER TABLE `Questions_in_Interview` ADD FOREIGN KEY (`Question_id`) REFERENCES `Questions` (`id`);
ALTER TABLE `Questions_in_Interview` ADD FOREIGN KEY (`Interview_id`) REFERENCES `Interview` (`id`);
ALTER TABLE `Candidate_Answers` ADD FOREIGN KEY (`Question_id`) REFERENCES `Questions_in_Interview` (`Question_id`);
ALTER TABLE `Questions` ADD FOREIGN KEY (`Question_Type_id`) REFERENCES `Type_of_Question` (`id`);