Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Specify the following queries in SQL on the following database schema (keys are in bold and underline): Consider the below schema of the university database

Specify the following queries in SQL on the following database schema (keys are in bold and underline):

Consider the below schema of the university database (keys are in bold and underline):

Students(stuID: String, stuName: String, gender: String, birthdate: Date, enterYear: Year, gpa: Float)

Departments(deptName: String, numPhDs: Integer)

ProfessorWorks(profID: String, profName: String, deptName: String)

CourseOffers(cNo: String, cTitle: String, deptName: String)

Majors(deptName: String, stuID: String, degreeProgram: String, attendSemester: String, attendYear: String)

Sections(cNo: String, academicYear: String, semester: String, sectNo: String, profID: String, meetsAt: String, room: String)

Enrolls(stuID: String, cNo: String, academicYear: String, semester: String, sectNo: String, grade: String)

These tables have been created and the data have been populated using MySQL server. Download DBHW4s17.sql to your computer and run it on MySQL. Execute your SQL statements based on these tables. Turn in your SQL queries statements and the results of these queries to the assignment link.

Write the following queries in SQL statements. The query answers must not contain duplicates, but you should use the SQL keyword DISTINCT only when necessary. When your SQL query statement is not accepted by MySQL, it will display error messages. You need to read that message and fix all problems accordingly. Note that MySQL does not support INTERSECT and EXCEPT currently. When you need to find the intersection and difference of two result sets, you can use IN and NOT IN instead. In addition, for this assignment, creation of temporary tables is not allowed, i.e., for each question you have to write exactly one SQL statement.

Print the name(s) of professor(s) who teaches class(es) for the Information Technology department. Note that Information Technology is a department name.

Print the names of departments that have one or more students whose GPA is above 3.50.

Print the age of the oldest and youngest student(s) per department. Note that MySQL provides several functions for performing calculations on DATE. The function TIMESTAMDIFF() can be used to convert the date of birth to age. Several examples are available at https://dev.mysql.com/doc/refman/5.7/en/date-calculations.html.

Print the name(s) and sid(s) of the student(s) enrolled in at least three classes in Fall 2016.

Find the names of students who have enrolled in both ITT 226 and Math 461 in Fall 2016. Note that ITT 226 and Math 461 are course numbers (cNo).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions