Question: Questions Problem 1 ( 1 0 pts ) . Read the following the previous section Prepare for SQL Coding. Run all the commands in the
Questions
Problem pts
Read the following the previous section Prepare for SQL Coding".
Run all the commands in the above example. Insert your own data in the three tables: Professor, Course, Teaching feel free to make up the values courses, departments, professors, etc. Insert a few rows in each of the tables
Try violating each of the primary key constraints by inserting rows with duplicate values of primary key columns Make a screenshot of each error message you see in MySQL when trying to insert two rows with the same primary key value. You should make a total of three screenshots here, one for violating each of the primary key constraints.
Try violating each of the foreign key constraints. Take screenshots of the error messages you see. You should have two screenshots here, one for each foreign key constraint.
Provide five screenshots of the results.
Provide the Qsql file that contains all your source code. here is the SQL: mysql create database xyz;
Query OK row affected sec
mysql use xyz;
Database changed
mysql CREATE TABLE Course
CrsCode varchar
DeptId varchar
CrsName varchar
Descr varchar
PRIMARY KEY CrsCode
UNIQUE DeptId CrsName
;
Query OK rows affected sec
mysql desc Course;
Field Type Null Key Default Extra
CrsCode varchar NO PRI NULL
DeptId varchar YES MUL NULL
CrsName varchar YES NULL
Descr varchar YES NULL
rows in set sec
mysql INSERT INTO Course VALUESCSCICS 'BIG DATA I 'Introduction to Big Data';
Query OK row affected sec
mysql INSERT INTO Course VALUESCSCICS 'Programming Languages', 'Formal definition of programming languages';
Query OK row affected sec
mysql SELECT FROM Course;
CrsCode DeptId CrsName Descr
CSCI CS Programming Languages Formal definition of programming languages
CSCI CS BIG DATA I Introduction to Big Data
rows in set sec
mysql CREATE TABLE Professor
Id integer PRIMARY KEY,
Name varchar
DeptId varchar
;
Query OK rows affected sec
mysql DESC Professor;
Field Type Null Key Default Extra
Id int NO PRI NULL
Name varchar YES NULL
DeptId varchar YES NULL
rows in set sec
mysql INSERT INTO Professor VALUES 'Weitian Tong', CS;
Query OK row affected sec
mysql CREATE TABLE Teaching
ProfId integer,
CrsCode varchar
Semester varchar
PRIMARY KEY CrsCode Semester
FOREIGN KEY CrsCode REFERENCES Course CrsCode
FOREIGN KEY ProfId REFERENCES Professor Id
;
Query OK rows affected sec
mysql desc Teaching;
Field Type Null Key Default Extra
ProfId int YES MUL NULL
CrsCode varchar NO PRI NULL
Semester varchar NO PRI NULL
rows in set sec
mysql INSERT INTO Teaching VALUES 'CSCIS;
Query OK row affected sec
mysql SELECT FROM Teaching;
ProfId CrsCode Semester
