CREATE TABLE IF NOT EXISTS practical_exam_components (
 exam_id BIGINT UNSIGNED NOT NULL,
 student_user_id BIGINT UNSIGNED NOT NULL,
 component VARCHAR(20) NOT NULL,
 feedback VARCHAR(2000) NULL,
 graded_by BIGINT UNSIGNED NOT NULL,
 updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 PRIMARY KEY(exam_id,student_user_id,component),
 FOREIGN KEY(exam_id,student_user_id) REFERENCES practical_exam_results(exam_id,student_user_id) ON DELETE CASCADE,
 FOREIGN KEY(graded_by) REFERENCES users(id),
 CHECK(component IN ('level_one','level_two','final_exam'))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
