USE sicherheitsunterweisung; SET FOREIGN_KEY_CHECKS = 0; 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; SET FOREIGN_KEY_CHECKS = 1; CREATE TABLE instructors ( id INT NOT NULL, first_name VARCHAR(32) NOT NULL, last_name VARCHAR(32) NOT NULL, PRIMARY KEY(id) ); CREATE TABLE briefings ( id INT AUTO_INCREMENT, date DATE NOT NULL, time TIME NOT NULL, location VARCHAR(32) NOT NULL, document_name VARCHAR(16) NOT NULL, as_of DATE NOT NULL, instructor_id INT NOT NULL, PRIMARY KEY(id), FOREIGN KEY(instructor_id) REFERENCES instructors(id) ); CREATE TABLE participants ( id INT AUTO_INCREMENT, first_name VARCHAR(32) NOT NULL, last_name VARCHAR(32) NOT NULL, company VARCHAR(32) NOT NULL, PRIMARY KEY(id) ); CREATE TABLE questions ( id INT AUTO_INCREMENT, 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 (id, first_name, last_name) VALUES ( '123456', 'Jason', 'Streifling' ), ( '123457', 'Tim', 'Taler' ), ( '123458', 'Georg', 'aus dem Jungel' ); INSERT INTO briefings ( date, time, location, document_name, as_of, instructor_id ) VALUES ( '2023-10-16', '17:00:00', 'Werk Langenhagen', 'ICS-2021-LGH', '2021-02-01', '123456' ), ( '2023-10-16', '17:05:00', 'Werk Langenhagen', 'ICS-2021-LGH', '2021-02-01', '123457' ); INSERT INTO participants ( first_name, last_name, company ) VALUES ( 'Peter', 'Enis', 'Körber' ), ( 'Dürüm', 'Döner', 'MP Technic' ); 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' ), ( 'Was ist 2+2?', '1', '2', '3', '4', '4' ), ( 'Was ist 0+1?', '1', '2', '3', '4', '1' ); 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' ), ( '2', '2', '1', '2' ), ( '2', '2', '2', '3' ), ( '2', '2', '3', '4' ), ( '2', '2', '4', '1' );