MySQL [toyu]> SELECT * FROM Student; +--------+-----------+----------+-------+-------+------+---------+ | stuId | fname | lname | major | minor | ach | advisor | +--------+-----------+----------+-------+-------+------+---------+ | 100000 | Tony | Hawk | CSCI | CINF | 40 | 1011 | | 100001 | Mary | Hawk | CSCI | CINF | 35 | 1011 | | 100002 | David | Hawk | CSCI | ITEC | 66 | 1012 | | 100003 | Catherine | Lim | ITEC | CINF | 20 | NULL | | 100004 | Larry | Johnson | ITEC | NULL | 66 | 1017 | | 100005 | Linda | Johnson | CINF | ENGL | 13 | 1015 | | 100006 | Lillian | Johnson | CINF | ITEC | 18 | 1016 | | 100007 | Ben | Zico | NULL | NULL | 16 | NULL | | 100008 | Bill | Ching | ARTS | NULL | 90 | NULL | | 100009 | Linda | King | ARTS | CSCI | 125 | 1018 | | 100111 | Cathy | Johanson | NULL | NULL | 0 | 1018 | +--------+-----------+----------+-------+-------+------+---------+ 11 rows in set (0.088 sec) MySQL [toyu]> desc student; +---------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+-------------+------+-----+---------+-------+ | stuId | int(11) | NO | PRI | NULL | | | fname | varchar(30) | NO | | NULL | | | lname | varchar(30) | NO | | NULL | | | major | char(4) | YES | MUL | NULL | | | minor | char(4) | YES | MUL | NULL | | | ach | int(3) | YES | | 0 | | | advisor | int(11) | YES | MUL | NULL | | +---------+-------------+------+-----+---------+-------+ 7 rows in set (0.017 sec) MySQL [toyu]> SELECT * FROM student; +--------+-----------+----------+-------+-------+------+---------+ | stuId | fname | lname | major | minor | ach | advisor | +--------+-----------+----------+-------+-------+------+---------+ | 100000 | Tony | Hawk | CSCI | CINF | 40 | 1011 | | 100001 | Mary | Hawk | CSCI | CINF | 35 | 1011 | | 100002 | David | Hawk | CSCI | ITEC | 66 | 1012 | | 100003 | Catherine | Lim | ITEC | CINF | 20 | NULL | | 100004 | Larry | Johnson | ITEC | NULL | 66 | 1017 | | 100005 | Linda | Johnson | CINF | ENGL | 13 | 1015 | | 100006 | Lillian | Johnson | CINF | ITEC | 18 | 1016 | | 100007 | Ben | Zico | NULL | NULL | 16 | NULL | | 100008 | Bill | Ching | ARTS | NULL | 90 | NULL | | 100009 | Linda | King | ARTS | CSCI | 125 | 1018 | | 100111 | Cathy | Johanson | NULL | NULL | 0 | 1018 | +--------+-----------+----------+-------+-------+------+---------+ 11 rows in set (0.003 sec) MySQL [toyu]> INSERT INTO Student(stuId, fname, lname, major, minor, ach, advisor) VALUES -> (100000,'Bun','Yue','CSCI','CINF',4,1011); ERROR 1062 (23000): Duplicate entry '100000' for key 'PRIMARY' MySQL [toyu]> MySQL [toyu]> INSERT INTO Student(stuId, fname, lname, major, minor, ach, advisor) VALUES -> (500000,'Bun','Yue','CSCI','CINF',4,1011); Query OK, 1 row affected (0.403 sec) MySQL [toyu]> SELECT * FROM student; +--------+-----------+----------+-------+-------+------+---------+ | stuId | fname | lname | major | minor | ach | advisor | +--------+-----------+----------+-------+-------+------+---------+ | 100000 | Tony | Hawk | CSCI | CINF | 40 | 1011 | | 100001 | Mary | Hawk | CSCI | CINF | 35 | 1011 | | 100002 | David | Hawk | CSCI | ITEC | 66 | 1012 | | 100003 | Catherine | Lim | ITEC | CINF | 20 | NULL | | 100004 | Larry | Johnson | ITEC | NULL | 66 | 1017 | | 100005 | Linda | Johnson | CINF | ENGL | 13 | 1015 | | 100006 | Lillian | Johnson | CINF | ITEC | 18 | 1016 | | 100007 | Ben | Zico | NULL | NULL | 16 | NULL | | 100008 | Bill | Ching | ARTS | NULL | 90 | NULL | | 100009 | Linda | King | ARTS | CSCI | 125 | 1018 | | 100111 | Cathy | Johanson | NULL | NULL | 0 | 1018 | | 500000 | Bun | Yue | CSCI | CINF | 4 | 1011 | +--------+-----------+----------+-------+-------+------+---------+ 12 rows in set (0.003 sec) MySQL [toyu]> INSERT INTO Student(stuId, fname, lname, major, minor, ach, advisor) VALUES -> (500099,'Bunlo','Yue','MUSI','CINF',45,3011); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`toyu`.`student`, CONSTRAINT `Student_major_fk` FOREIGN KEY (`major`) REFERENCES `department` (`deptCode`) ON DELETE CASCADE) MySQL [toyu]> MySQL [toyu]> INSERT INTO Department(deptCode, deptName, schoolCode, numStaff) VALUES -> ('MUSI','Music','CSE',8); Query OK, 1 row affected (0.233 sec) MySQL [toyu]> INSERT INTO Student(stuId, fname, lname, major, minor, ach, advisor) VALUES -> (500099,'Bunlo','Yue','MUSI','CINF',45,3011); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`toyu`.`student`, CONSTRAINT `Student_advisor_fk` FOREIGN KEY (`advisor`) REFERENCES `faculty` (`facId`)) MySQL [toyu]> INSERT INTO Faculty(facId, fname, lname, deptCode, `rank`) VALUES -> (3011,'Paula','Smithson','MUSI','Professor'); Query OK, 1 row affected (0.063 sec) MySQL [toyu]> INSERT INTO Student(stuId, fname, lname, major, minor, ach, advisor) VALUES -> (500099,'Bunlo','Yue','MUSI','CINF',45,3011); Query OK, 1 row affected (0.017 sec) MySQL [toyu]> source createtoyu.sql Query OK, 0 rows affected (0.002 sec) Query OK, 0 rows affected (0.003 sec) Query OK, 0 rows affected (0.002 sec) Query OK, 8 rows affected (1.218 sec) Query OK, 1 row affected (0.030 sec) Database changed Query OK, 0 rows affected, 1 warning (0.012 sec) Query OK, 0 rows affected, 1 warning (0.005 sec) Query OK, 0 rows affected, 1 warning (0.004 sec) Query OK, 0 rows affected, 1 warning (0.004 sec) Query OK, 0 rows affected, 1 warning (0.005 sec) Query OK, 0 rows affected, 1 warning (0.032 sec) Query OK, 0 rows affected, 1 warning (0.005 sec) Query OK, 0 rows affected, 1 warning (0.004 sec) Query OK, 0 rows affected (0.204 sec) Query OK, 0 rows affected (0.157 sec) Query OK, 0 rows affected (0.144 sec) Query OK, 0 rows affected (0.132 sec) Query OK, 0 rows affected (0.136 sec) Query OK, 0 rows affected (0.096 sec) Query OK, 0 rows affected, 1 warning (0.178 sec) Query OK, 0 rows affected (0.623 sec) ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FUNCTION GetStudentFullName( student_id INT ) RETURNS VARCHAR(61) DETERMINIS' at line 1 ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FUNCTION GetDepartmentName( dept_code CHAR(4) ) RETURNS VARCHAR(30) DETERMIN' at line 1 ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FUNCTION GetStudentGPA( student_id INT ) RETURNS DECIMAL(3,2) DETERMINISTIC ' at line 1 ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FUNCTION GetTopStudentsInDepartment( dept_code CHAR(4), top_count INT ) ' at line 1 ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PROCEDURE AddNewCourse( IN course_id INT, IN rubric CHAR(4), IN cour' at line 1 Query OK, 15 rows affected (0.016 sec) Records: 15 Duplicates: 0 Warnings: 0 Query OK, 4 rows affected (0.006 sec) Records: 4 Duplicates: 0 Warnings: 0 Query OK, 7 rows affected (0.009 sec) Records: 7 Duplicates: 0 Warnings: 0 Query OK, 11 rows affected (0.006 sec) Records: 11 Duplicates: 0 Warnings: 0 Query OK, 11 rows affected (0.007 sec) Records: 11 Duplicates: 0 Warnings: 0 Query OK, 14 rows affected (0.008 sec) Records: 14 Duplicates: 0 Warnings: 0 Query OK, 11 rows affected (0.035 sec) Records: 11 Duplicates: 0 Warnings: 0 Query OK, 22 rows affected (0.007 sec) Records: 22 Duplicates: 0 Warnings: 0 Query OK, 0 rows affected, 1 warning (0.006 sec) Query OK, 0 rows affected (0.002 sec) Query OK, 0 rows affected (0.002 sec) MySQL [toyu]> notee