Directions (Q96–100): Use the following schema of an academic institution's relational database:
student (rollno, name, degree, year, sex, deptno, advisor) department (deptid, name, hod, phone) professor (empid, name, sex, startyear, deptno, phone) course (courseid, cname, credits, deptno) enrollment (rollno, courseid, sem, year, grade) teaching (empid, courseid, sem, year, classroom) prerequisite (precourseid, courseid)
deptno in student, professor and course refers to department.deptid; advisor (student) and hod (department) refer to professor.empid; rollno in enrollment refers to student; courseid in enrollment and teaching refers to course; empid in teaching refers to professor; precourseid and courseid in prerequisite refer to course.
Given the query
SELECT s.rollno, s.name FROM student s WHERE EXISTS (SELECT c.courseid FROM course c WHERE c.deptno = 5 AND EXISTS (SELECT e.* FROM enrollment e WHERE e.courseid = c.courseid AND e.rollno = s.rollno));
which statement is correct?
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: C. It retrieves students who have enrolled in at least one course offered by department 5.
Explanation
EXISTS … EXISTS means there is some department-5 course in which the student is enrolled, i.e. at least one.More Database Management Systems questions
- Identify the incorrect statement.
- Consider the two relations below (primary keys: EMP.eid and DEPT.did). Identify all possible foreign key(s) based only on the two relations…
- Which of the following statements is correct according to the following instance of the relational schema R(X, Y, Z)?X Y Z 1 1 a 1 1 a 2 1…
- What are the drawbacks of using file systems to store data? 1. Data inconsistency 2. Difficulty in accessing data 3. Data isolation 4. Atom…
- In which of the following database models do we have a parent-child relationship? 1. Hierarchical databases 2. Network databases 3. Relatio…
- Identify the correct operation that produces the given output from the two relations R1 and R2.R1 Name Class a1 9 b1 5 c1 6 d1 11 R2 Name C…