Introduction To Database Systems - Unit 7 - Week 5
Introduction To Database Systems - Unit 7 - Week 5
courseId is a foreign key in the enrollment, teaching relations referring to courseId of course relation;
Which of the following SQL sub-language constructs are used to insert rows into tables? 2 points
DDL
DML
Transaction control language
None of the above
No, the answer is incorrect.
Score: 0
Accepted Answers:
DML
Which of the following relational calculus operators does not have an equivalent keyword in SQL? 2 points
exists (∃)
for all (∀)
and (∧)
None of the above
No, the answer is incorrect.
Score: 0
Accepted Answers:
for all (∀)
Suppose that in the given schema, we want to change the teaching table and add an extra column called 2 points
‘teachingAssistant’. A teaching assistant is a student who assists the professor of a course in clarifying student-
doubts, setting up quizzes and evaluating students etc. Assume that each course is allotted at most one teaching
assistant. Which of the following commands is suitable to enforce the above requirement?
Only (i)
Only (ii)
Only (ii) and (iii)
All (i), (ii) and (iii)
No, the answer is incorrect.
Score: 0
Accepted Answers:
Only (ii) and (iii)
Suppose that in the given schema, the PRIMARY KEY of preRequisite table is only “courseId”. Then, which2 points
of the following statement(s) is(are) TRUE in all data instances of the database?
Every course in course table (specified in courseId column) has at least one prerequisite
Every course in course table (specified in courseId column) has exactly one prerequisite
Every course in preRequisite table (specified in courseId column) has exactly one prerequisite
All of the above
No, the answer is incorrect.
Score: 0
Accepted Answers:
Every course in preRequisite table (specified in courseId column) has exactly one prerequisite
Suppose we need to find the roll numbers of students whose grades are neither ‘U’ nor ‘W’ in the course 2 points
having id ‘CS123’. What is the correct SQL query?
SELECT e1.rollNo
FROM enrollment e1
WHERE EXISTS (SELECT * FROM enrollment e2
WHERE e1.rollNo = e2. rollNo and e1.courseId = e2.courseId)
SELECT e1.rollNo
FROM enrollment e1
WHERE EXISTS (SELECT * FROM enrollment e2
WHERE e1.rollNo = e2. rollNo and e1.courseId = e2.courseId
and e1.year = e2.year and e1.sem = e2.sem)
SELECT e1.rollNo
FROM enrollment e1
WHERE EXISTS (SELECT * FROM enrollment e2
WHERE e1.rollNo = e2. rollNo and e1.courseId = e2.courseId
and e1.year != e2.year and e1.sem != e2.sem)
SELECT e1.rollNo
FROM enrollment e1
WHERE EXISTS (SELECT * FROM enrollment e2
WHERE e1.rollNo = e2. rollNo and e1.courseId = e2.courseId
and (e1.year != e2.year or e1.sem != e2.sem))
No, the answer is incorrect.
Score: 0
Accepted Answers:
SELECT e1.rollNo
FROM enrollment e1
WHERE EXISTS (SELECT * FROM enrollment e2
WHERE e1.rollNo = e2. rollNo and e1.courseId = e2.courseId
and (e1.year != e2.year or e1.sem != e2.sem))
Consider the following query to retrieve the most senior professor (determined based on startYear) : 2 points
SELECT p1.name
FROM professor p1
WHERE p1.startYear ---------- (SELECT p2.startYear
FROM professor p2)
Which of the following options is the correct filler for the blank ?
> ALL
>= ALL
>= ANY
IN
No, the answer is incorrect.
Score: 0
Accepted Answers:
>= ALL
Which of the following queries would find the courses with at least two prerequisites? 2 points
SELECT *
FROM course c1
WHERE EXISTS (SELECT * FROM prerequisite p1
WHERE p1.courseId = c1.courseId)
AND EXISTS (SELECT * FROM prerequisite p2
WHERE p2.courseId = c1.courseId)
SELECT *
FROM course c1
WHERE EXISTS (SELECT * FROM prerequisite p1
WHERE p1.courseId = c1.courseId)
AND EXISTS (SELECT * FROM prerequisite p2
WHERE p2.courseId = c1.courseId
AND p1.preCourseId <> p2.preCourseId)
SELECT *
FROM course c1
WHERE EXISTS (SELECT * FROM prerequisite p1, prerequisite p2
WHERE p1.courseId = c1.courseId
AND p2.courseId = c1. courseId)
SELECT *
FROM course c1
WHERE EXISTS (SELECT * FROM prerequisite p1, prerequisite p2
WHERE p1.courseId = c1.courseId
AND p2.courseId = c1. courseId
AND p1.preCourseId <> p2.preCourseId)
No, the answer is incorrect.
Score: 0
Accepted Answers:
SELECT *
FROM course c1
WHERE EXISTS (SELECT * FROM prerequisite p1, prerequisite p2
WHERE p1.courseId = c1.courseId
AND p2.courseId = c1. courseId
AND p1.preCourseId <> p2.preCourseId)
Consider the following query 2 points
The query executes only if rollNo of student and empId of professor have same data types
The query executes in all cases (irrespective of the data types of rollNo and empId)
The query does not execute at all
None of the above
No, the answer is incorrect.
Score: 0
Accepted Answers:
The query executes only if rollNo of student and empId of professor have same data types