0% found this document useful (0 votes)
60 views

IMSE 685 Manufacturing Information Systems Homework Assignment #3

This document provides instructions for homework assignment 3 in the IMSE 685 Manufacturing Information Systems course. Students are asked to: 1) Create tables in a MySQL database to represent student, course, prerequisite, section, and grade data. 2) Populate the tables with sample data. 3) Write SQL queries to retrieve and manipulate data, including listing students, grades, updating records. The homework is due by November 10th 2020 and should be submitted as a written report with SQL statements.

Uploaded by

MARYAM shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

IMSE 685 Manufacturing Information Systems Homework Assignment #3

This document provides instructions for homework assignment 3 in the IMSE 685 Manufacturing Information Systems course. Students are asked to: 1) Create tables in a MySQL database to represent student, course, prerequisite, section, and grade data. 2) Populate the tables with sample data. 3) Write SQL queries to retrieve and manipulate data, including listing students, grades, updating records. The homework is due by November 10th 2020 and should be submitted as a written report with SQL statements.

Uploaded by

MARYAM shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

IMSE 685 Manufacturing Information Systems

Homework Assignment #3
Due Date: Tuesday Nov 10th, 2020 11:59pm

MySQL Database and SQL Language Practice

 Two plus pages written report will be required for this project.
 Include all the SQL statements question by question with additional explanations.
 This project will be performed with maximal two students.
 The project papers will not be handed back.

Please hand in the report with the appropriate answers to the questions. Below each question,
please add the SQL statement (or answer the question) you used to complete the requirements.

1. Create new tables in SQL in a blank database


2. Input the data into MySQL Server database
3. Run SQL statements

(I) Create the schema in IMSE685 database with the following tables (60 points):
STUDENT
Name StudentID Class Major

COURSE
CourseName CourseNo CreditHour DepartmentID

PREREQUISITE
CourseNo PrerequisiteNo

SECTION
SecitonID CourseNo Semester Year Instructor

GRADE_REPORT
StudentID SectionID Grade

Figure 1. Student Academia Record Database Schema

(II) Insert 5 records (sample data) for each of the following tables using K-State KSIS format:
Note that the provided sample data only has few entries. You can required to populate data of 5
students/courses.
SQL code to generate data tables and data entery
CREATE TABLE `imse685`.`STUDENT` (
`StudentID` INT(11) NOT NULL,
`Name` VARCHAR(50) NOT NULL,
`Class` VARCHAR(50) NOT NULL,
`Major` VARCHAR(50) NOT NULL,
PRIMARY KEY (`StudentID`)
) ENGINE =MyISAM;

CREATE TABLE `imse685`.`COURSE` (


`CourseID` INT(11) NOT NULL,
`CourseNo` VARCHAR(50) NOT NULL,
`CourseName` VARCHAR(50) NOT NULL,
`CreditHour` INT(3) NOT NULL,
`DepartmentID` VARCHAR(5) NOT NULL,
PRIMARY KEY (`CourseID`)
) ENGINE =MyISAM;

CREATE TABLE `imse685`.`PREREQUISITE` (


`PrerequisiteID` INT(11) NOT NULL AUTO_INCREMENT,
`CourseNo` VARCHAR(50) NOT NULL,
`PrerequisiteNo` VARCHAR(50) NOT NULL,
PRIMARY KEY (`PrerequisiteID`)
) ENGINE =MyISAM;

CREATE TABLE `imse685`.`SECTION` (


`SectionID` INT(11) NOT NULL,
`CourseNo` VARCHAR(50) NOT NULL,
`Semester` VARCHAR(10) NOT NULL,
`Year` INT(2) NOT NULL,
`InstructorName` VARCHAR(50) NOT NULL,
PRIMARY KEY (`SectionID`)
) ENGINE =MyISAM;

CREATE TABLE `imse685`.`GRADE_REPORT` (


`ReportID` INT(11) NOT NULL AUTO NUMBER,
`StudentID` VARCHAR(50) NOT NULL,
`SectionID` VARCHAR(10) NOT NULL,
`Grade` VARCHAR(2) NOT NULL,

PRIMARY KEY (`ReportID`)


) ENGINE =MyISAM;
INSERT INTO student (studentID, Name, Class,Major)
VALUES (17, Smith, 1,CS);
INSERT INTO student (studentID, Name, Class,Major)
VALUES (8, 'Brown', 1,'CS');

ALTER TABLE course


ADD CourseName varchar(40) NOT NULL
AFTER CourseNo;

INSERT INTO course (CourseID,


CourseNo,CreditHour,DepartmentID,CourseName)
VALUES (1, 'CS1310',4,'CS','Intro to Computer Sciences');

INSERT INTO course (CourseID,


CourseNo,CreditHour,DepartmentID,CourseName)
VALUES (2, 'CS3320',4,'CS','DataStructure');

INSERT INTO course (CourseID,


CourseNo,CreditHour,DepartmentID,CourseName)
VALUES (3, 'MATH2410',3,'MATH','DiscreteMathematics');
INSERT INTO course (CourseID,
CourseNo,CreditHour,DepartmentID,CourseName)
VALUES (4, 'CS3380',3,'CS','Database');

INSERT INTO section (SectionID, CourseNo,Semester,Year,InstructorName)


VALUES (85, 'MATH2410','Fall',07,'King');

INSERT INTO section (SectionID, CourseNo,Semester,Year,InstructorName)


VALUES (92, 'CS1310','Fall',07,'Anderson');
INSERT INTO section (SectionID, CourseNo,Semester,Year,InstructorName)
VALUES (102, 'CS3320','Spring',08,'Knuth');
INSERT INTO section (SectionID, CourseNo,Semester,Year,InstructorName)
VALUES (112, 'MATH2410','Fall',08,'Chang');
INSERT INTO section (SectionID, CourseNo,Semester,Year,InstructorName)
VALUES (119, 'CS1310','Fall',08,'Anderson');
INSERT INTO section (SectionID, CourseNo,Semester,Year,InstructorName)
VALUES (135, 'CS3380','Fall',08,'Stone');

INSERT INTO GRADE_REPORT (ReportID, StudentID,SectionID,Grade)


VALUES (1,17, 112,'B');
INSERT INTO GRADE_REPORT (StudentID,SectionID,Grade)
VALUES (17, 119,'C');
INSERT INTO GRADE_REPORT (StudentID,SectionID,Grade)
VALUES (8, 85,'A');
INSERT INTO GRADE_REPORT (StudentID,SectionID,Grade)
VALUES (8, 92,'A');
INSERT INTO GRADE_REPORT (StudentID,SectionID,Grade)
VALUES (8, 102,'B');
INSERT INTO GRADE_REPORT (StudentID,SectionID,Grade)
VALUES (8, 135,'A');

INSERT INTO prerequisite(prerequisiteID, CourseNo,PrerequisiteNo)


VALUES (1,'CS3380', 'CS3320');
INSERT INTO prerequisite(CourseNo,PrerequisiteNo)
VALUES ('CS3380', 'MATH2410');
INSERT INTO prerequisite(CourseNo,PrerequisiteNo)
VALUES ('CS3320', 'CS1310');
(II) SQL Exercises (40 points)
For this part of assignment, use MySQL account:
Database: IMSE685 (Do not change the contents of this database)
All the same data instances have been imported from Microsoft Access. Show SQL Statements
for the following:

1. Show a list of all Students in accessing order with last name.

In the data table generated as requested in above (I), there is table STUDENT in which a column
Name exists.

Just to get names

SELECT name
FROM student
ORDER BY name ASC;

All information to get students name list and other information

SELECT *
FROM student
ORDER BY name ASC;
2. Show grades of students with names of students and course name as well.

SELECT student.name,section.CourseNo,grade_report.Grade
FROM grade_report
INNER JOIN student ON student.StudentID = grade_report.StudentID
INNER JOIN section ON section.SectionID = grade_report.SectionID
ORDER BY name ;

3. Show list of students who has never received a grade below B in any course.

SELECT Name From student


where studentid=(
SELECT DISTINCT StudentID
FROM grade_report gr1
WHERE gr1.Grade in ("A" ,"B")

AND NOT EXISTS(


SELECT 1
From grade_report
Where Grade="C"
AND StudentID=gr1.StudentID)
AND NOT EXISTS(
SELECT 1
From grade_report
Where Grade="D"
AND StudentID=gr1.StudentID)
)

4. Write a command to insert details of one more student.

INSERT INTO student (studentID, Name, Class, Major)


VALUES (17, Smith, 1, CS);

5. One of the courses now has a different prerequisite. Change the prerequisite table
as needed.

If there is required to remove previous previous entery which is not required then we can update

DELETE FROM prerequisite


WHERE courseID = ‘CourseID’ AND prerequisite =’PrequisiteNo’;

INSERT INTO prerequisite (CourseNo,PrerequisiteNo)


VALUES ('CourseID ', 'NewPrerequisite');

Using update command, we can update previous

UPDATE prerequisite
SET prequisiteNo = ‘NewprerequisiteNo’
WHERE CourseID =’CourseID’ AND prerequisite =’PrequisiteNoOLD’;

For addition of new prerequisite course in data table, we just need to use INSERT
INSERT INTO prerequisite (CourseNo, PrerequisiteNo)
VALUES ('CourseID ', 'NewPrerequisite');

6. Pick one instructor from your table and show which department course he is
teaching.

SELECT DepartmentID,CourseName
From course
WHERE CourseNo =(SELECT CourseNo From section Where
InstructorName="King")

7. List courses who has credit hours more than 3.

SELECT CourseName, CreditHour


From course
WHERE CreditHour>3
SELECT CourseName, CreditHour
From course
WHERE CreditHour>=3

8. One student’s grade has changed after completing extra assignments. Write a
command to do that.
Smith grade has been changed from B to A for Section ID 112. For this purpose, update query
was applied.

UPDATE `grade_report` SET Grade ="A"


WHERE StudentID=(Select StudentID from student Where Name = "Smith") AND
SectionID=112;

You might also like