Question

In: Computer Science

I am having a hard time writing these SQL queries. Please specify the following queries in...

I am having a hard time writing these SQL queries. Please specify the following queries in SQL on the database schema shown in the figure below.

STUDENT
Name StudentNumber Class Major
Smith 17 1 CS
Brown 8 2 CS
Kathy 15 1 EE
COURSE
CourseName CourseNumber CreditHours Department
Intro to Computer Science CSE110 4 CS
Data Structures CSE205 4 CS
Discrete Mathematics MAT240 3 MATH
Databases CSE380 3 CS
Analog Circuits EE260 3 EE
SECTION
SectionIdentifier CourseNumber Semester Year Instructor
85 MAT240 Fall 2010 King
92 CSE110 Fall 2010 Chang
102 CSE205 Spring 2011 King
112 MAT240 Fall 2011 Chang
119 CSE110 Fall 2011 Anderson
135 CSE380 Fall 2011 Stone
146 EE260 Fall 2011 James
GRADE REPORT
StudentNumber SectionIdentifier Grade
17 112 B
17 119 C
8 85 A
8 92 A
8 102 B
8 135 A
15 146 A
PREREQUISITE
CourseNumber PreRequisiteNumber
CSE380 CSE205
CSE380 MAT240
CSE205 CSE110
EE260 MAT240

1) Retrieve the course names of all courses with the number of credit hours as 4

2) Retrieve the names of all courses and their respective departments taught by professor Chang in 2010 and 2011

3) For each section taught by Professor King, retrieve the course number, semester, year, and the number of students who took the section

4) Retrieve the name and transcript of each freshman student (Class=1) majoring in EE. Transcript includes course name, course number, credit hours, semester, year, and grade for each course completed by the student

Solutions

Expert Solution

Answer:

1) Retrieve the course names of all courses with the number of credit hours as 4

Select CourseName,CreditHours from COURSE where CreditHours = 4

Output:

CourseName CreditHours
Intro to Computer Science 4
Data Structures 4

2) Retrieve the names of all courses and their respective departments taught by professor Chang in 2010 and 2011

Select co.CourseName,co.Department,se.Instructor,se.Year from Course co
join Section se on se.CourseNumber = co.CourseNumber
where se.Year in ('2010','2011') and se.Instructor = "Chang" order by co.CourseName;

Output:

CourseName Department Instructor Year
Intro to Computer Science CS Chang 2010
Discrete Mathematics MATH Chang 2011

3) For each section taught by Professor King, retrieve the course number, semester, year, and the number of students who took the section

Select se.CourseNumber,se.Semester,se.Year,count(gr.StudentNumber)as " Total Students" from SECTION se
join GradeReport gr on gr.SectionIdentifier = se.SectionIdentifier
where se.Instructor = "King" group by se.SectionIdentifier ;

Output:

CourseNumber Semester Year Total Students
MAT240 Fall 2010 1
CSE205 Spring 2011 1

4) Retrieve the name and transcript of each freshman student (Class=1) majoring in EE. Transcript includes course name, course number, credit hours, semester, year, and grade for each course completed by the student

Select st.Name,c.CourseName,c.CourseNumber,c.CreditHours,s.Semester,s.Year,g.Grade from Course c
join Section s on s.CourseNumber = c.CourseNumber
join GradeReport g on g.SectionIdentifier = s.SectionIdentifier
join Student st on st.StudentNumber = g.StudentNumber
where st.class = 1 and st.Major = "EE" order by Name;

Output:

Name CourseName CourseNumber CreditHours Semester Year Grade
Kathy Analog Circuits EE260 3 Fall 2011 A

Thanks and all the best. Let me know in case if you have any doubts.


Related Solutions

I am having trouble writing these queries in MYSQL. Using the schema listed below, please write...
I am having trouble writing these queries in MYSQL. Using the schema listed below, please write the following queries in MYSQL: 1) Find the Content and the Reviewer Name for each comment, about “ACADEMY DINOSAUR” only if the same reviewer has commented about “ACE GOLDFINGER” too. 2) Retrieve the title of all the Movies in Japanese without any comment, ordered alphabetically. 3) Find all the movie titles where an actor called “TOM” or an actor called “BEN" acted, where there...
I understand the answer to this I am just having a hard time creating a graph...
I understand the answer to this I am just having a hard time creating a graph for it. Bill the butcher is upset because the government plans to tax beef $.10 a pound. "I hate paying taxes," he says. "Because of this, I'm raising all my beef prices by $.10 a pound. The consumers will bear this burden, not me." Do you see anything wrong with this way of thinking? Explain. Draw a graph describing your answer and attach it...
I am having a hard time getting started on how to do this assignment. I would...
I am having a hard time getting started on how to do this assignment. I would like some ideas on how to start the MEMO. and maybe some ideas on what you would include. But I don't necessarily need the assignment completed for me. just need ideas!!! One routine negative message in the form of an internal memo. 400-500 word message. Single-spaced, with 1-inch margins on all sides. Objective: To announce organizational restructuring, one routine negative message addressed to employees....
I have figured out this assignment, but I am having a hard time figuring out the...
I have figured out this assignment, but I am having a hard time figuring out the extra credit, Thanks! Creating a Rectangle class We have created a representation of a rectangle in C++ and extended it to create multiple representation's of rectangles. Classes can simplify that process considerably. In this assignment, your task is to convert the representation of a rectangle we created earlier in the semester to a Rectangle class. The Rectangle class shall consist of the following: The...
C# programming. Comment/Explain the below code line by line. I am having a hard time following...
C# programming. Comment/Explain the below code line by line. I am having a hard time following it. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Nth_prime {     class Program     {         public static bool isPrime(int number)         {             int counter = 0;             for (int j = 2; j < number; j++)             {                 if (number % j == 0)                 {                     counter = 1;                     break;                 }             }             if (counter == 0)             {                 return true;             }             else             {                 return false;             }         }...
can someone explain to me what osmolality is.? i am having a hard time understanding it
can someone explain to me what osmolality is.? i am having a hard time understanding it
I am having a hard time getting my an output after putting in the second set...
I am having a hard time getting my an output after putting in the second set of functions and I was hoping to be able to have the results from the functions be rounded to 2 decimal places. <html> <head> <title>Length Conversion</title> <script language='JavaScript' type='text/JavaScript'> <!-- function validate(type) { if(document.my_form.textinput.value=='') { alert('Fill the Input box before submitting'); return false; }else{ if(type=="to_feet"){ var res=3.2808*document.my_form.textinput.value; var unit=" feet"; }else{ var res=0.3048*document.my_form.textinput.value; var unit=" meter"; } document.getElementById("result").innerHTML=res.toFixed(2) + unit; return false; } }...
I am having a hard time understanding these two questions. If someone can explain that would...
I am having a hard time understanding these two questions. If someone can explain that would be great. 1) Explain the steps that enables body to metabolize fat to ATP? 2) Write out the amount of ATP, NADH, FADH2 produced in each step of cellular metabolism of a glucose.
For some reason I am having a hard time getting this program to compile properly. Could...
For some reason I am having a hard time getting this program to compile properly. Could you help me debug it? Write the prototypes and functions to overload the given operators in the code //main.cpp //This program shows how to use the class rectangleType. #include <iostream> #include "rectangleType.h" using namespace std; int main() {     rectangleType rectangle1(23, 45);                     //Line 1     rectangleType rectangle2(12, 10);                     //Line 2     rectangleType rectangle3;                             //Line 3     rectangleType rectangle4;                             //Line 4     cout << "Line...
Hello, I am having a hard time being able to fully understand how firm strategy, technology...
Hello, I am having a hard time being able to fully understand how firm strategy, technology and investment affects the emergence of the digital gaming industry? Please go into great detail.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT