-- Create surveys table CREATE TABLE IF NOT EXISTS `surveys` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `description` text DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Create questions table CREATE TABLE IF NOT EXISTS `questions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `survey_id` int(11) NOT NULL, `question_text` text NOT NULL, `question_type` enum('text','textarea','radio','checkbox','select') NOT NULL, PRIMARY KEY (`id`), KEY `survey_id` (`survey_id`), CONSTRAINT `questions_ibfk_1` FOREIGN KEY (`survey_id`) REFERENCES `surveys` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Create question_options table CREATE TABLE IF NOT EXISTS `question_options` ( `id` int(11) NOT NULL AUTO_INCREMENT, `question_id` int(11) NOT NULL, `option_text` varchar(255) NOT NULL, PRIMARY KEY (`id`), KEY `question_id` (`question_id`), CONSTRAINT `question_options_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;