-
-
Save friveroll/94c964af9eba1b6c7c5b to your computer and use it in GitHub Desktop.
Database for a Chemistry Quiz using cxsmiles as structures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; | |
SET time_zone = "+00:00"; | |
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | |
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | |
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | |
/*!40101 SET NAMES utf8 */; | |
-- | |
-- ChemistryQuiz database | |
-- | |
-- -------------------------------------------------------- | |
-- | |
-- structure `category` table | |
-- | |
CREATE TABLE IF NOT EXISTS `category` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`unit_id` int(10) unsigned NOT NULL, | |
`texto` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`), | |
KEY `unit_id` (`unit_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; | |
-- -------------------------------------------------------- | |
-- | |
-- structure `questionTxt` table | |
-- | |
CREATE TABLE IF NOT EXISTS `questionTxt` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`texto` text COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; | |
-- -------------------------------------------------------- | |
-- | |
-- structure of `structure` table | |
-- | |
CREATE TABLE IF NOT EXISTS `structure` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`cxsmiles` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`isAnswer` tinyint(4) NOT NULL, | |
`isQuestion` tinyint(4) NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; | |
-- | |
-- structure `oneStructureQuestion` table | |
-- | |
CREATE TABLE IF NOT EXISTS `oneStructureQuestion` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`structure_id` int(10) unsigned NOT NULL, | |
`questionTxt_id` int(10) unsigned NOT NULL, | |
`question_id` int(10) unsigned NOT NULL, | |
PRIMARY KEY (`id`), | |
KEY `structure_id` (`structure_id`), | |
KEY `questionTxt_id` (`questionTxt_id`), | |
KEY `question_id` (`question_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; | |
-- -------------------------------------------------------- | |
-- | |
-- structure `questions` table | |
-- | |
CREATE TABLE IF NOT EXISTS `questions` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`QuestionType` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`category_id` int(10) unsigned NOT NULL, | |
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', | |
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', | |
PRIMARY KEY (`id`), | |
KEY `QuestionType` (`QuestionType`), | |
KEY `category_id` (`category_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; | |
-- -------------------------------------------------------- | |
-- | |
-- structure `subunit` table | |
-- | |
CREATE TABLE IF NOT EXISTS `subunit` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`unit_id` int(10) unsigned NOT NULL, | |
`texto` text COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`), | |
KEY `unit_id` (`unit_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; | |
-- -------------------------------------------------------- | |
-- | |
-- structure `QuestionType` table | |
-- | |
CREATE TABLE IF NOT EXISTS `QuestionType` ( | |
`QuestionType` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`QuestionType`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- -------------------------------------------------------- | |
-- | |
-- structure `unit` table | |
-- | |
CREATE TABLE IF NOT EXISTS `unit` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`texto` text COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; | |
-- | |
-- Restrictions | |
-- | |
-- | |
-- Filters `category` table | |
-- | |
ALTER TABLE `category` | |
ADD CONSTRAINT `category_ibfk_1` FOREIGN KEY (`unit_id`) REFERENCES `unit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; | |
-- | |
-- Filters `oneStructureQuestion` table | |
-- | |
ALTER TABLE `oneStructureQuestion` | |
ADD CONSTRAINT `oneStructureQuestion_ibfk_3` FOREIGN KEY (`structure_id`) REFERENCES `structure` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
ADD CONSTRAINT `oneStructureQuestion_ibfk_4` FOREIGN KEY (`questionTxt_id`) REFERENCES `questionTxt` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
ADD CONSTRAINT `oneStructureQuestion_ibfk_5` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; | |
-- | |
-- Filters `questions` table | |
-- | |
ALTER TABLE `questions` | |
ADD CONSTRAINT `questions_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
ADD CONSTRAINT `questions_ibfk_1` FOREIGN KEY (`QuestionType`) REFERENCES `QuestionType` (`QuestionType`) ON DELETE CASCADE ON UPDATE CASCADE; | |
-- | |
-- Filters `subunit` table | |
-- | |
ALTER TABLE `subunit` | |
ADD CONSTRAINT `subunit_ibfk_1` FOREIGN KEY (`unit_id`) REFERENCES `unit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; | |
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | |
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | |
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment