Created
December 31, 2017 13:05
-
-
Save ajfmo/d66c0d4532827832925baa966becc6c7 to your computer and use it in GitHub Desktop.
Database script
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
CREATE DATABASE `students` /*!40100 DEFAULT CHARACTER SET utf8 */; | |
use students; | |
CREATE TABLE `career` ( | |
`career_id` varchar(25) NOT NULL, | |
`career_name` varchar(100) NOT NULL, | |
PRIMARY KEY (`career_id`), | |
UNIQUE KEY `career_name_UNIQUE` (`career_name`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
CREATE TABLE `section` ( | |
`section_id` varchar(25) NOT NULL, | |
`section_name` varchar(45) NOT NULL, | |
PRIMARY KEY (`section_id`), | |
UNIQUE KEY `section_name_UNIQUE` (`section_name`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
CREATE TABLE `student` ( | |
`student_id` varchar(50) NOT NULL, | |
`student_name` varchar(100) NOT NULL, | |
`student_career` varchar(100) NOT NULL, | |
`student_section` varchar(100) NOT NULL, | |
PRIMARY KEY (`student_id`), | |
UNIQUE KEY `idstudent_UNIQUE` (`student_id`), | |
KEY `fk_student_section_idx` (`student_section`), | |
KEY `fk_student_career_idx` (`student_career`), | |
CONSTRAINT `fk_student_career` FOREIGN KEY (`student_career`) REFERENCES `career` (`career_name`) ON DELETE NO ACTION ON UPDATE NO ACTION, | |
CONSTRAINT `fk_student_section` FOREIGN KEY (`student_section`) REFERENCES `section` (`section_id`) ON DELETE NO ACTION ON UPDATE NO ACTION | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment