CREATE TABLE `thematic_questions` (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `expert_id` int(11) DEFAULT NULL COMMENT 'Expert to whom the question is assigned',
  `thematic_id` int(11) UNSIGNED NOT NULL,
  `user_id` int(11) UNSIGNED NOT NULL COMMENT 'Student that do the question',
  `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `description` text COLLATE utf8_unicode_ci,
  `answered` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0-No answers, 1-Already answered',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ALTER TABLE `thematic_questions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_thematic_questions_users1_idx` (`user_id`),
  ADD KEY `fk_thematic_questions_thematics1_idx` (`thematic_id`),
  ADD KEY `fk_thematic_questions_experts1_idx` (`expert_id`);

ALTER TABLE `thematic_questions`
  ADD CONSTRAINT `fk_thematic_questions_thematics1` FOREIGN KEY (`thematic_id`) REFERENCES `thematics` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  ADD CONSTRAINT `fk_thematic_questions_experts1` FOREIGN KEY (`expert_id`) REFERENCES `experts` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  ADD CONSTRAINT `fk_thematic_questions_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
