2023-11-01 14:11:00 +01:00
|
|
|
/*
|
|
|
|
* Sicherheitsunterweisung
|
|
|
|
* Copyright (C) 2023 Jason Streifling
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2023-10-16 18:51:52 +02:00
|
|
|
USE sicherheitsunterweisung;
|
2023-10-19 20:06:28 +02:00
|
|
|
|
|
|
|
SET FOREIGN_KEY_CHECKS = 0;
|
2023-10-16 18:51:52 +02:00
|
|
|
DROP TABLE IF EXISTS instructors;
|
|
|
|
DROP TABLE IF EXISTS briefings;
|
|
|
|
DROP TABLE IF EXISTS participants;
|
|
|
|
DROP TABLE IF EXISTS questions;
|
|
|
|
DROP TABLE IF EXISTS given_answers;
|
2023-10-19 20:06:28 +02:00
|
|
|
SET FOREIGN_KEY_CHECKS = 1;
|
2023-10-16 18:51:52 +02:00
|
|
|
|
|
|
|
CREATE TABLE instructors (
|
2023-10-28 08:01:34 +02:00
|
|
|
id INT NOT NULL,
|
|
|
|
first_name VARCHAR(32) NOT NULL,
|
|
|
|
last_name VARCHAR(32) NOT NULL,
|
2023-10-16 18:51:52 +02:00
|
|
|
|
|
|
|
PRIMARY KEY(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE briefings (
|
2023-10-28 08:01:34 +02:00
|
|
|
id INT AUTO_INCREMENT,
|
2023-11-01 13:11:50 +01:00
|
|
|
datetime DATETIME NOT NULL,
|
2023-10-16 18:51:52 +02:00
|
|
|
location VARCHAR(32) NOT NULL,
|
2023-11-01 13:11:50 +01:00
|
|
|
document VARCHAR(16) NOT NULL,
|
2023-10-16 18:51:52 +02:00
|
|
|
as_of DATE NOT NULL,
|
|
|
|
instructor_id INT NOT NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY(id),
|
|
|
|
FOREIGN KEY(instructor_id) REFERENCES instructors(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE participants (
|
2023-10-28 08:01:34 +02:00
|
|
|
id INT AUTO_INCREMENT,
|
2023-10-16 18:51:52 +02:00
|
|
|
first_name VARCHAR(32) NOT NULL,
|
|
|
|
last_name VARCHAR(32) NOT NULL,
|
|
|
|
company VARCHAR(32) NOT NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE questions (
|
2023-10-28 08:01:34 +02:00
|
|
|
id INT AUTO_INCREMENT,
|
2023-10-16 18:51:52 +02:00
|
|
|
question VARCHAR(256) NOT NULL,
|
|
|
|
answer_1 VARCHAR(64) NOT NULL,
|
|
|
|
answer_2 VARCHAR(64) NOT NULL,
|
|
|
|
answer_3 VARCHAR(64) NOT NULL,
|
|
|
|
answer_4 VARCHAR(64) NOT NULL,
|
|
|
|
correct_answer INT NOT NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE given_answers (
|
|
|
|
briefing_id INT NOT NULL,
|
|
|
|
participant_id INT NOT NULL,
|
|
|
|
question_id INT NOT NULL,
|
|
|
|
given_answer INT NOT NULL,
|
|
|
|
|
|
|
|
PRIMARY KEY(briefing_id, participant_id, question_id),
|
|
|
|
FOREIGN KEY(briefing_id) REFERENCES briefings(id),
|
|
|
|
FOREIGN KEY(participant_id) REFERENCES participants(id),
|
|
|
|
FOREIGN KEY(question_id) REFERENCES questions(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO instructors
|
2023-10-28 08:01:34 +02:00
|
|
|
(id, first_name, last_name)
|
2023-10-16 18:51:52 +02:00
|
|
|
VALUES
|
2023-11-01 13:11:50 +01:00
|
|
|
( '100000', 'Jason', 'Streifling' ),
|
|
|
|
( '100001', 'Peter', 'Enis' );
|
|
|
|
|
|
|
|
--INSERT INTO briefings (
|
|
|
|
-- datetime, location, document, as_of, instructor_id
|
|
|
|
--) VALUES
|
|
|
|
-- ( '2023-10-16 17:00:00', 'Werk Langenhagen', 'ICL-1901-LGH', '2021-02-01', '100000' ),
|
|
|
|
-- ( '2023-10-16 17:05:00', 'Werk Langenhagen', 'ICL-1901-LGH', '2021-02-01', '100001' );
|
|
|
|
--
|
|
|
|
--INSERT INTO participants (
|
|
|
|
-- first_name, last_name, company
|
|
|
|
--) VALUES
|
|
|
|
-- ( 'Max', 'Mustermann', 'ABC GmbH' ),
|
|
|
|
-- ( 'Gustav', 'Gans', 'ABC GmbH' ),
|
|
|
|
-- ( 'Klara', 'Kakerlake', 'DEF KG' );
|
|
|
|
--
|
2023-10-16 18:51:52 +02:00
|
|
|
INSERT INTO questions (
|
|
|
|
question, answer_1, answer_2, answer_3, answer_4, correct_answer
|
|
|
|
) VALUES
|
|
|
|
( 'Was ist 1+1?', '1', '2', '3', '4', '2' ),
|
|
|
|
( 'Was ist 1+2?', '1', '2', '3', '4', '3' ),
|
2023-10-19 20:06:28 +02:00
|
|
|
( 'Was ist 2+2?', '1', '2', '3', '4', '4' ),
|
|
|
|
( 'Was ist 0+1?', '1', '2', '3', '4', '1' );
|
2023-11-01 13:11:50 +01:00
|
|
|
--
|
|
|
|
--INSERT INTO given_answers (
|
|
|
|
-- briefing_id, participant_id, question_id, given_answer
|
|
|
|
--) VALUES
|
|
|
|
-- ( '1', '1', '1', '2' ),
|
|
|
|
-- ( '1', '1', '2', '3' ),
|
|
|
|
-- ( '1', '1', '3', '3' ),
|
|
|
|
-- ( '1', '1', '4', '1' ),
|
|
|
|
-- ( '1', '2', '1', '2' ),
|
|
|
|
-- ( '1', '2', '2', '3' ),
|
|
|
|
-- ( '1', '2', '3', '3' ),
|
|
|
|
-- ( '1', '2', '4', '1' ),
|
|
|
|
-- ( '2', '3', '1', '2' ),
|
|
|
|
-- ( '2', '3', '2', '3' ),
|
|
|
|
-- ( '2', '3', '3', '4' ),
|
|
|
|
-- ( '2', '3', '4', '1' );
|