Question: Execute the following SQL and successfully create two tables, employee and department. # SET FOREIGN_KEY_CHECKS=1; # # DROP DATABASE IF EXISTS `COMPANY`; # CREATE DATABASE
Execute the following SQL and successfully create two tables, employee and department.
# SET FOREIGN_KEY_CHECKS=1; # # DROP DATABASE IF EXISTS `COMPANY`; # CREATE DATABASE `COMPANY`; # USE `COMPANY`;
# TABLE: `COMPANY`.`employee` CREATE TABLE `employee` ( `Fname` varchar(15) NOT NULL, `Minit` char(1) DEFAULT NULL, `Lname` varchar(15) NOT NULL, `SSN` char(9) NOT NULL, `bdate` date DEFAULT NULL, `Address` varchar(30) DEFAULT NULL, `sex` varchar(2) DEFAULT NULL, `Salary` decimal(10,2) DEFAULT NULL, `Super_ssn` char(9) DEFAULT NULL, `Dno` int(11) NOT NULL, PRIMARY KEY (`SSN`), CONSTRAINT `employee_ibfk_1` FOREIGN KEY (`Dno`) REFERENCES `department` (`dnumber`) ); # TABLE: `COMPANY`.`department` CREATE TABLE `department` ( `dname` varchar(15) NOT NULL, `dnumber` int(11) NOT NULL, `mgr_ssn` char(9) NOT NULL, `mgr_start_date` date DEFAULT NULL, PRIMARY KEY (`dnumber`), UNIQUE KEY `dname` (`dname`), KEY `mgr_ssn` (`mgr_ssn`), CONSTRAINT `department_ibfk_1` FOREIGN KEY (`mgr_ssn`) REFERENCES `employee` (`SSN`) ) ;
#drop table department; #drop table employee;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
