Question

STUDENTS (StudentID, StudentName, Year, Phone) COURSE (CourseID, CourseName, CourseDate, InstructorID) ENROLLMENT (StudentID, CourseID, Grade) where: StudentID...

STUDENTS (StudentID, StudentName, Year, Phone) COURSE (CourseID, CourseName, CourseDate, InstructorID) ENROLLMENT (StudentID, CourseID, Grade) where: StudentID in ENROLLMENT must exist in StudentID in Student CourseID in ENROLLMENT must exist in CourseID in COURSE Sample data for these tables are shown as follows. STUENTS Data StudentID StudentName Year Phone 1 Allen 1 123-456-1111 2 Bill 2 123-456-2222 COURSE Data CourseID CourseName CourseDate InstructorID BUS349-001 Database Fall2020 F001 BUS381-001 Data Analytics Spring2020 F001 MAT102-001 Intro to Math Spring2020 F101 ENROLLMENT StudentID CourseID Score 1 BUS349-001 100 1 BUS381-001 90 Based on this case, answer the following questions. 1. (5 pts) Write a SQL CREATE TABLE statement to create the ENROLLMENT table, with EnrollmentID as a surrogate key. Justify your choices of column properties. 2. (5 pts) Write SQLs to insert the data into the ENROLLMENT, COURSE, and STUDENT tables. You only need to insert the first line. 3. (5pts) Write an SQL statement to display all columns of all rows of STUDENTS. 4. (5pts) Write an SQL statement to display student name of all students who are in their first year. 5. (5pts) Write an SQL statement to display the InstructorID column without duplications. 6. (5pts) Write an SQL statement to display the student name who takes the course of BUS349 with the instructor of F001. 7. (5pts) Write an SQL statement to display the student name, courses they take, and score in a desc order. 8. (5pts) Write an SQL statement to count the number of courses offered in Fall 2020. 9. (5pts) Write an SQL statement to count the number of courses offered in Spring semester. 10. (5pts) Write SQL statements to display the average score of each course. 11. (5pts) Write an SQL statement to delete STUDENT table. 12. (5pts) Write an SQL statement to change the instructor from F001 to F002 for the course of “BUS309-001” 13. (Bonus, 5pts) Write an SQL statement to display the minimum, maximum, and average score of each college. We assume the first three characters of CourseID indicates the college information.

Homework Answers

Answer #1

1. CREATE TABLE COURSE(
CourseID varchar(20) PRIMARY KEY,
CourseName varchar(50),
CourseDate varchar(15),
InstructorID varchar(5));

CREATE TABLE STUDENTS(  
StudentID INT PRIMARY KEY,  
StudentName VARCHAR(20), 
Year INT,  
Phone VARCHAR(15));

CREATE TABLE ENROLLMENT(

EnrollmentID NUMBER GENERATED ALWAYS AS IDENTITY,
StudentID NUMBER FOREIGN KEY REFERENCES STUDENTS(StudentID) ,
CourseID VARCHAR(20) FOREIGN KEY REFERENCES COURSE(CourseID),
Grade NUMBER);

Justifications for ENROLLMENT Table Columns Properties:

a. EnrollmentID is autogenerated as it is a surrogate key. Hence, EnrollmentID is defined as a number or integer value.

b. StudentID in ENROLLMENT is a FOREIGN KEY which REFERENCES StudentID in STUDENTS. Also, StudentID is an integer,hence it is defined as a NUMBER.

c. CourseID in COURSE is a FOREIGN KEY which REFERENCES CourseID in COURSE.CourseID has both numbers and alphabets.Hence,it is defined as VARCHAR with size 20.

d. Grade ranges from 0-100 and hence it is defined as an integer or a NUMBER.

2. INSERT INTO ENROLLMENT VALUES (1,'BUS349-001',100 );

INSERT INTO STUDENTS VALUES (1,'Allen',1, '123-456-1111' );

INSERT INTO COURSE VALUES ('BUS349-001', 'Database', 'Fall2020', 'F001' );

NOTE: You can insert other rows of the table also in a similar manner.

3. SELECT * FROM STUDENTS;

4. SELECT StudentName from STUDENTS where Year=1;

NOTE: If you need answers to other sub-parts also please post it as a separate question.

Please upvote if you liked the answer :)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please check my work. The purpose of this exercise is to provide students with the opportunity...
Please check my work. The purpose of this exercise is to provide students with the opportunity to normalize data. Assignment: Identify what fields from the list below belong to which table. If you are uncertain, place the field under the column with your argument on why it should belong. Write your answers in the columns below the table names. COURSE FACULTY LOCATION SECTION STUDENT CourseID CourseNumber CourseName CreditHours Status Description Days StartTime EndTime FacultyID Status FirstName LastName WorkPhone HomePhone CellPhone...
Consider the following data.    STUDENT StudentID SName Gender Age ClubID 3234 Alfred Smith Male 20...
Consider the following data.    STUDENT StudentID SName Gender Age ClubID 3234 Alfred Smith Male 20 BSK 2244 McJohnson Robert Male 22 2389 Jessica Low Female 20 JPA 4211 Roland Devingo Male 24 4383 Jane Usa Khan Female 21 BKY 4450 Elaine Fong Female 20 JPA CLUB ClubID CName Founded Budget BKY Bakery Club 2010 2546 PDC Photomedia and Design 2005 1345 JPA Japanese Anime 2009 3453 BSK Basketball 2011 6744 Write an SQL statement to display student name and...
please fix code to delete by studentname import java.util.Scanner; public class COurseCom666 {     private String...
please fix code to delete by studentname import java.util.Scanner; public class COurseCom666 {     private String courseName;     private String[] students = new String[1];     private int numberOfStudents;     public COurseCom666(String courseName) {         this.courseName = courseName;     }     public String[] getStudents() {         return students;     }     public int getNumberOfStudents() {         return numberOfStudents;     }     public void addStudent(String student) {         if (numberOfStudents == students.length) {             String[] a = new String[students.length + 1];            ...
Data structures in java Implement the following classes: 1. class Course that includes three instance variables:...
Data structures in java Implement the following classes: 1. class Course that includes three instance variables: private String Name; // the course name private int ID; // the course ID private Course next; // the link Your class should have the following:  A constructor that initializes the two instance variables id and name.  Set and get methods for each instance variable. 2. class Department that includes three instance variables: private String deptName; private Course head, tail; Your class...
Lab 5 Queries with Multiple Tables In this lab, we do queries more than one table....
Lab 5 Queries with Multiple Tables In this lab, we do queries more than one table. SQL provides two different techniques for querying data from multiple tables: • The SQL subquery • The SQL join As you will learn, although both work with multiple tables, they are used for slightly different purposes. We used WMCRM database which is what we created in Lab 4. Here is the summary of the database schema (where schema is used in its meaning of...
Using JAVA Resource: "Starter Code to Access Tables via JDBC" text file ******** PASTED BELOW ****************...
Using JAVA Resource: "Starter Code to Access Tables via JDBC" text file ******** PASTED BELOW **************** For this assignment, you will create Java™ code that accesses a relational database, requests data, and then analyzes and displays a portion of that data. Imagine that a MySQL relational database schema named COMPANY_DB containing two tables, employee_table and payroll_table, such that the records in each of the tables is as follows: ·        employee_table: Emp id FName   LNname Addr City State Zip 100 Jack...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you start doing anything… This project involves implementing a simple university personnel management program. The program contains two different kinds of objects: students and faculty. For each object, the program stores relevant information such as university ID, name, etc. Different information is stored depending on the type of the object. For example, a student has a GPA, while a faculty has a title and department...
Plagiarism Certification Tests for Undergraduate College Students and Advanced High School Students These tests are intended...
Plagiarism Certification Tests for Undergraduate College Students and Advanced High School Students These tests are intended for undergraduate students in college or those under 18 years of age. Read these directions carefully! The below test includes 10 questions, randomly selected from a large inventory. Most questions will be different each time you take the test, You must answer at least 9 out of 10 questions correctly to receive your Certificate. You have 40 minutes to complete each test, and you...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT