The following query is intended to list IDs and names of all students taking HIS 118. However, this query does not work properly. Briefly explain why and show the corrected SQL query. SELECT stuD, firstName, lastName FROM Students, Enrolls WHERE classNumber = 'HIS 118';

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
The following query is intended to list IDs and names of all students taking HIS 118. However, this query does not work properly. Briefly explain why and show the corrected SQL query. SELECT stuD, firstName, lastName FROM Students, Enrolls WHERE classNumber = 'HIS 118';
### Relational Database Overview

Let us consider the following relational database:

- **Students**(`stuID`, lastName, firstName, major, credits)
- **Faculty**(`facID`, name, deptName, rank)
- **Classes**(`classNumber`, facID, schedule, room)
- **Enrolls**(`stuID`, `classNumber`, grade)

The primary keys are underlined. The referential integrity constraints are as follows:

- The column `facID` of relation **Classes** references table **Faculty**.
- The column `stuID` of relation **Enrolls** references table **Students**.
- The column `classNumber` of relation **Enrolls** references table **Classes**.

### Explanation of Diagrams and Constraints

#### Diagram/Diagram Explanation
There are no diagrams accompanying this text. However, to visualize these relationships, consider the following:

1. **Tables and Relationships**:
   - **Students Table**: Contains essential student information such as student ID, last name, first name, major, and the number of completed credits.
   - **Faculty Table**: Lists faculty members with details like faculty ID, name, department name, and academic rank.
   - **Classes Table**: Includes class details with a unique class number, linked faculty ID, schedule, and room allocation.
   - **Enrolls Table**: Maps student enrollments to classes with columns for student ID, class number, and the grade received.

2. **Primary Keys**:
   - `stuID` in **Students**.
   - `facID` in **Faculty**.
   - `classNumber` in **Classes**.
   - Composite key (`stuID`, `classNumber`) in **Enrolls**.

3. **Referential Integrity Constraints**:
   - **Classes.facID** references **Faculty.facID**, ensuring each class is associated with an existing faculty member.
   - **Enrolls.stuID** references **Students.stuID**, ensuring all recorded enrollments are for existing students.
   - **Enrolls.classNumber** references **Classes.classNumber**, ensuring enrollments are tied to existing classes.
Transcribed Image Text:### Relational Database Overview Let us consider the following relational database: - **Students**(`stuID`, lastName, firstName, major, credits) - **Faculty**(`facID`, name, deptName, rank) - **Classes**(`classNumber`, facID, schedule, room) - **Enrolls**(`stuID`, `classNumber`, grade) The primary keys are underlined. The referential integrity constraints are as follows: - The column `facID` of relation **Classes** references table **Faculty**. - The column `stuID` of relation **Enrolls** references table **Students**. - The column `classNumber` of relation **Enrolls** references table **Classes**. ### Explanation of Diagrams and Constraints #### Diagram/Diagram Explanation There are no diagrams accompanying this text. However, to visualize these relationships, consider the following: 1. **Tables and Relationships**: - **Students Table**: Contains essential student information such as student ID, last name, first name, major, and the number of completed credits. - **Faculty Table**: Lists faculty members with details like faculty ID, name, department name, and academic rank. - **Classes Table**: Includes class details with a unique class number, linked faculty ID, schedule, and room allocation. - **Enrolls Table**: Maps student enrollments to classes with columns for student ID, class number, and the grade received. 2. **Primary Keys**: - `stuID` in **Students**. - `facID` in **Faculty**. - `classNumber` in **Classes**. - Composite key (`stuID`, `classNumber`) in **Enrolls**. 3. **Referential Integrity Constraints**: - **Classes.facID** references **Faculty.facID**, ensuring each class is associated with an existing faculty member. - **Enrolls.stuID** references **Students.stuID**, ensuring all recorded enrollments are for existing students. - **Enrolls.classNumber** references **Classes.classNumber**, ensuring enrollments are tied to existing classes.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Multiple table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education