Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
103 views

Introduction To Database Systems - Unit 7 - Week 5

The document provides information about an assignment that was due on March 1, 2023. It includes the schema of an academic institution database with tables for students, departments, professors, courses, enrollments, teaching assignments, and course prerequisites. It then asks a series of multiple choice questions about SQL queries and relational operations on the database schema.

Uploaded by

Arunkumar M
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views

Introduction To Database Systems - Unit 7 - Week 5

The document provides information about an assignment that was due on March 1, 2023. It includes the schema of an academic institution database with tables for students, departments, professors, courses, enrollments, teaching assignments, and course prerequisites. It then asks a series of multiple choice questions about SQL queries and relational operations on the database schema.

Uploaded by

Arunkumar M
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Week 5: Assignment 5

The due date for submitting this assignment has passed.


Due on 2023-03-01, 23:59 IS
As per our records you have not submitted this assignment.
Use the following schema of the academic institution relational database in the following questions wherever
required.

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 is a foreign key in the student, professor and course relations referring to deptId of department relation;

advisor is a foreign key in the student relation referring to empId of professor relation;

hod is a foreign key in the department relation referring to empId of professor relation;

rollNo is a foreign key in the enrollment relation referring to rollNo of student relation;

courseId is a foreign key in the enrollment, teaching relations referring to courseId of course relation;

empId is a foreign key of the teaching relation referring to empId of professor relation;

preCourseId and courseId are foreign keys in the preRequisite relation referring to courseId of the 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?

 ALTER TABLE teaching ADD teachingAssistant VARCHAR(10);


 ALTER TABLE teaching ADD teachingAssistant VARCHAR(10) NOT NULL;
 ALTER TABLE teaching ADD teachingAssistant VARCHAR(10) REFERENCES professor(empId);
 ALTER TABLE teaching ADD teachingAssistant VARCHAR(10) REFERENCES student(rollNo);
No, the answer is incorrect.
Score: 0
Accepted Answers:
ALTER TABLE teaching ADD teachingAssistant VARCHAR(10) REFERENCES student(rollNo);
Which of the following are unique keys in the teaching table definition? 2 points
(i) empId, courseId, year (ii) empId, courseId, sem, year (iii) empId, courseId, sem, year, classRoom

 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 rollNo FROM enrollment


where courseId = ‘CS123’ and grade != ‘U’ or grade != ‘W’
 SELECT rollNo FROM enrollment
where courseId = ‘CS123’ and NOT (grade != ‘U’ and grade != ‘W’)
 SELECT rollNo FROM enrollment
where courseId = ‘CS123’ and grade NOT EXISTS (‘U’, ‘W’);
 SELECT rollNo FROM enrollment
where courseId = ‘CS123’ and grade NOT IN (‘U’, ‘W’);
No, the answer is incorrect.
Score: 0
Accepted Answers:
SELECT rollNo FROM enrollment
where courseId = ‘CS123’ and grade NOT IN (‘U’, ‘W’);
Which of the following queries would find the students who enrolled in a course twice (Note that a course is 2 points
usually offered once in a year but some popular courses are offered in both the semesters of the same year)?

 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

SELECT rollNo as identifier


FROM student
UNION
SELECT empId as identifier
FROM professor

Which of the following statements is correct regarding the above query?

 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

You might also like