0% found this document useful (0 votes)
25 views

Introduction to Database Systems - - Unit 8 - Week 5

This document outlines the Week 5 assignment for the Introduction to Database Systems course, focusing on SQL and relational database concepts. It includes a schema for an academic institution's database and presents various SQL-related questions for students to answer. The assignment emphasizes understanding of data manipulation, foreign keys, and SQL query formulation.

Uploaded by

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

Introduction to Database Systems - - Unit 8 - Week 5

This document outlines the Week 5 assignment for the Introduction to Database Systems course, focusing on SQL and relational database concepts. It includes a schema for an academic institution's database and presents various SQL-related questions for students to answer. The assignment emphasizes understanding of data manipulation, foreign keys, and SQL query formulation.

Uploaded by

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

2/26/25, 10:02 AM Introduction to Database Systems - - Unit 8 - Week 5

(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)

[email protected]

NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » Introduction to Database Systems (course)


Click to register
for Certification
exam
Week 5 : Assignmnet 5
(https://examform.nptel.ac.in/2025_01/exam_form/dashboard)
Your last recorded submission was on 2025-02-26, 09:14 Due date: 2025-02-26, 23:59 IST.
IST
If already
Use the following schema of the academic institution relational database in the following
registered, click
questions wherever required.
to check your
payment status
student(rollNo, name, degree, year, sex, deptNo, advisor)
department(deptId, name, hod, phone)
professor(empId, name, sex, startYear, deptNo, phone)
Course course(courseId, cname, credits, deptNo)
outline enrollment(rollNo, courseId, sem, year, grade)
teaching(empId, courseId, sem, year, classRoom)
preRequisite(preCourseId, courseId)
About
NPTEL ()
deptNo is a foreign key in the student, professor and course relations referring to deptId of
department relation;
Introduction
to Database
Systems () advisor is a foreign key in the student relation referring to empId of professor relation;

Week 0 () hod is a foreign key in the department relation referring to empId of professor relation;

Week 1 () rollNo is a foreign key in the enrollment relation referring to rollNo of student relation;

Week 2 () courseId is a foreign key in the enrollment, teaching relations referring to courseId of course
relation;
Week 3 ()
empId is a foreign key of the teaching relation referring to empId of professor relation;

Week 4 ()
preCourseId and courseId are foreign keys in the preRequisite relation referring to courseId of
the course relation.
Week 5 ()

https://onlinecourses.nptel.ac.in/noc25_cs40/unit?unit=47&assessment=181 1/5
2/26/25, 10:02 AM Introduction to Database Systems - - Unit 8 - Week 5

Data 1) Which of the following SQL sub-language constructs are used to insert rows into 2 points
definition tables?
using SQL
(unit? DDL
unit=47&lesso DML
n=48)
Transaction control language
Basic SQL None of the above
query block
and
2) Which of the following relational calculus operators does not have an equivalent 2 points
subqueries
keyword in SQL?
(unit?
unit=47&lesso
exists (∃)
n=49)
for all (∀)
Correlated
and (∧)
subqueries
(unit? None of the above
unit=47&lesso
n=50) 3) Suppose that in the given schema, we want to change the teaching table and add 2 points
Lecture Slides
an extra column called ‘teachingAssistant’. A teaching assistant is a student who assists the
(unit? professor of a course in clarifying student-doubts, setting up quizzes and evaluating students etc.
unit=47&lesso Assume that each course is allotted at most one teaching assistant. Which of the following
n=51) commands is suitable to enforce the above requirement?

Week 5 ALTER TABLE teaching ADD teachingAssistant VARCHAR(10);


Feedback
ALTER TABLE teaching ADD teachingAssistant VARCHAR(10) NOT NULL;
Form :
Introduction ALTER TABLE teaching ADD teachingAssistant VARCHAR(10) REFERENCES
to Database professor(empId);
Systems!!
ALTER TABLE teaching ADD teachingAssistant VARCHAR(10) REFERENCES
(unit?
student(rollNo);
unit=47&lesso
n=52)
4) Which of the following are unique keys in the teaching table definition? 2 points
Quiz: Week 5 (i) empId, courseId, year (ii) empId, courseId, sem, year (iii) empId, courseId, sem, year,
: Assignmnet
classRoom
5
(assessment?
Only (i)
name=181)
Only (ii)
Week 6 () Only (ii) and (iii)
All (i), (ii) and (iii)
Download
Videos ()
5) Suppose that in the given schema, the PRIMARY KEY of preRequisite table is only2 points
“courseId”. Then, which of the following statement(s) is(are) TRUE in all data instances of the
Lecture
database?
Notes ()
Every course in course table (specified in courseId column) has at least one prerequisite
Problem
Every course in course table (specified in courseId column) has exactly one prerequisite
Solving
Session - Every course in preRequisite table (specified in courseId column) has exactly one
Jan 2025 () prerequisite
All of the above

https://onlinecourses.nptel.ac.in/noc25_cs40/unit?unit=47&assessment=181 2/5
2/26/25, 10:02 AM Introduction to Database Systems - - Unit 8 - Week 5

6) Suppose we need to find the roll numbers of students whose grades are neither ‘U’2 points
nor ‘W’ in the course 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’);

7) Which of the following queries would find the students who enrolled in a course 2 points
twice (Note that a course is 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))

8) Consider the following query to retrieve the most senior professor (determined 2 points
based on startYear) :
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

https://onlinecourses.nptel.ac.in/noc25_cs40/unit?unit=47&assessment=181 3/5
2/26/25, 10:02 AM Introduction to Database Systems - - Unit 8 - Week 5

9) Which of the following queries would find the courses with at least two 2 points
prerequisites?

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)

10) 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

You may submit any number of times before the due date. The final submission will be
considered for grading.

Submit Answers

https://onlinecourses.nptel.ac.in/noc25_cs40/unit?unit=47&assessment=181 4/5
2/26/25, 10:02 AM Introduction to Database Systems - - Unit 8 - Week 5

https://onlinecourses.nptel.ac.in/noc25_cs40/unit?unit=47&assessment=181 5/5

You might also like