Created
May 22, 2014 21:46
-
-
Save cjcjameson/706f8782916a5a01164e to your computer and use it in GitHub Desktop.
FamilyTreeSQL
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
-- --- | |
-- Globals | |
-- --- | |
-- SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; | |
-- SET FOREIGN_KEY_CHECKS=0; | |
-- --- | |
-- Table 'People' | |
-- | |
-- --- | |
DROP TABLE IF EXISTS `People`; | |
CREATE TABLE `People` ( | |
`id` INTEGER NULL AUTO_INCREMENT DEFAULT NULL, | |
`name` MEDIUMTEXT NULL DEFAULT NULL, | |
`mother_id` INTEGER NULL DEFAULT NULL, | |
`father_id` INTEGER NULL DEFAULT NULL, | |
`gender` MEDIUMTEXT NULL DEFAULT NULL, | |
`birthday` DATE NULL DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
); | |
-- --- | |
-- Foreign Keys | |
-- --- | |
ALTER TABLE `People` ADD FOREIGN KEY (mother_id) REFERENCES `People` (`id`); | |
ALTER TABLE `People` ADD FOREIGN KEY (mother_id) REFERENCES `People` (`id`); | |
ALTER TABLE `People` ADD FOREIGN KEY (father_id) REFERENCES `People` (`id`); | |
ALTER TABLE `People` ADD FOREIGN KEY (father_id) REFERENCES `People` (`id`); | |
-- --- | |
-- Table Properties | |
-- --- | |
-- ALTER TABLE `People` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; | |
-- --- | |
-- Test Data | |
-- --- | |
-- INSERT INTO `People` (`id`,`name`,`mother_id`,`father_id`,`gender`,`birthday`) VALUES | |
-- ('','','','','',''); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment