UGC NET · PAPER 2
UGC NET Paper 2 Computer Science – Unit 4: Database Management Systems PYQ (December 2022 Shift 1)
Q13. A ______ operation combines the rows of two relations and outputs a new relation that has both input relations' rows in it.
- difference
- union
- cartesian product
- project
Q14. Consider the relation R(P, Q, R, S, T, U, V, W, X, Y) and FDs: {P, Q, S} → T, R → Y, {P, Q} → V, {R, X} → X, Q → U, V → {W, X}. Which of the following is a candidate key?
- {P, Q, R, S}
- {R, Q, X}
- {V, X}
- None of the above
Q49. Let T1 be a transaction that transfers Rs. 50 from account A to account B: 1 Read(A); 2 A := A − 50; 3 Write(A); 4 Read(B); 5 B := B + 50; 6 Write(B). What is the status of the database just after the 3rd step but before the 5th step?
- Always consistent
- May be temporarily inconsistent
- Must abort
- Always roll back
Q50. Consider Student(stuid, dept, clsroll) with FD1: stuid → dept, FD2: dept → stuid, FD3: stuid → clsroll, FD4: clsroll → stuid, FD5: dept → clsroll. Which functional dependencies can be removed to obtain a canonical cover?
A. FD2 and FD3
B. FD1 and FD5
C. FD5
D. FD1
Choose the correct answer from the options given below:
A. FD2 and FD3
B. FD1 and FD5
C. FD5
D. FD1
Choose the correct answer from the options given below:
- A, B only
- A, C only
- B, C only
- A, B, C only
Q69. Match List I with List II
| List I | List II |
|---|---|
| A. Timestamp protocol | I. As long as the transaction is running, it obtains the required locks in the first phase. |
| B. Strict two-phase locking protocol | II. Indicates the final lock of the schedule. |
| C. Two-phase locking | III. Ensures freedom from deadlock. |
| D. Lock point in two-phase locking protocol | IV. Ensures cascadeless rollback. |
- A-III, B-IV, C-II, D-I
- A-III, B-IV, C-I, D-II
- A-IV, B-III, C-II, D-I
- A-IV, B-II, C-I, D-III
Q79. Consider the schedule S (operations at successive timestamps t1–t6):
t1: T2 R(X), T3 R(Y)
t2: T2 W(X), T3 W(Y)
t3: T1 R(Y), T4 R(X)
t4: T1 W(Y), T4 W(X)
t5: T3 R(X)
t6: T3 W(X)
Choose the correct (conflict-equivalent) serial execution order for the schedule S.
t1: T2 R(X), T3 R(Y)
t2: T2 W(X), T3 W(Y)
t3: T1 R(Y), T4 R(X)
t4: T1 W(Y), T4 W(X)
t5: T3 R(X)
t6: T3 W(X)
Choose the correct (conflict-equivalent) serial execution order for the schedule S.
- T3 − T2 − T1 − T4
- T2 − T3 − T1 − T4
- T2 − T4 − T3 − T1
- T4 − T2 − T3 − T1
Q87. Statement I: Any retrieval request that can be specified in basic relational algebra can also be specified in relational calculus.
Statement II: Any retrieval request that can be specified in relational calculus can also be specified in basic relational algebra.
Statement II: Any retrieval request that can be specified in relational calculus can also be specified in basic relational algebra.
- Both Statement I and Statement II are true.
- Both Statement I and Statement II are false.
- Statement I is true but Statement II is false.
- Statement I is false but Statement II is true.
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.
Q96. Which of the following queries would retrieve the roll numbers and names of students who have enrolled in ALL the prerequisite courses of course number 324?
SELECT s.rollno, s.name FROM student s, enrollment e WHERE e.rollno = s.rollno AND e.courseid = ANY (SELECT precourseid FROM prerequisite p WHERE p.courseid = '324')
SELECT s.rollno, s.name FROM student s, enrollment e WHERE e.rollno = s.rollno AND e.courseid = ALL (SELECT precourseid FROM prerequisite p WHERE p.courseid = '324')
SELECT s.rollno, s.name FROM student s WHERE NOT EXISTS (SELECT * FROM prerequisite p WHERE p.courseid = '324' AND NOT EXISTS (SELECT * FROM enrollment e WHERE e.courseid = p.precourseid AND e.rollno = s.rollno))SELECT s.rollno, s.name FROM student s WHERE EXISTS (SELECT * FROM prerequisite p WHERE p.courseid = '324' AND EXISTS (SELECT * FROM enrollment e WHERE e.courseid = p.precourseid AND e.rollno = s.rollno))
Q97. Given the query
SELECT s.rollno FROM student s WHERE s.sex = ALL (SELECT f.sex FROM professor f WHERE f.empid = s.advisor);
which retrieves students whose gender is the same as their advisor's. Consider:
S1. It has a correlated subquery.
S2. It has an uncorrelated subquery.
S3. If we replace ALL by ANY, the result will be different.
S4. If we replace ALL by ANY, the result will be the same.
Identify the TRUE statements:
SELECT s.rollno FROM student s WHERE s.sex = ALL (SELECT f.sex FROM professor f WHERE f.empid = s.advisor);
which retrieves students whose gender is the same as their advisor's. Consider:
S1. It has a correlated subquery.
S2. It has an uncorrelated subquery.
S3. If we replace ALL by ANY, the result will be different.
S4. If we replace ALL by ANY, the result will be the same.
Identify the TRUE statements:
- S1 and S3 are true
- S1 and S4 are true
- S2 and S3 are true
- S2 and S4 are true
Q98. Which of the following queries computes, for each department, the total credits of all the courses offered by the department?
SELECT deptid, name, SUM(credits) AS totalcredits FROM department, course WHERE deptid = deptno GROUP BY deptid, name;
SELECT deptid, name, COUNT(credits) AS totalcredits FROM department, course WHERE deptid = deptno GROUP BY deptid, name;
SELECT deptid, name, SUM(credits) AS totalcredits FROM department, course;
SELECT deptid, name, SUM(credits) AS totalcredits FROM department, course GROUP BY deptid, name HAVING deptid = deptno;
Q99. Which of the following queries retrieves the deptid and name of all departments whose total credits of offered courses is strictly greater than 40?
SELECT deptid, name, SUM(credits) AS totalcredits FROM department, course WHERE totalcredits > 40 GROUP BY deptid, name HAVING deptid = deptno;
SELECT deptid, name, SUM(credits) AS totalcredits FROM department, course WHERE deptid = deptno AND totalcredits > 40 GROUP BY deptid, name;
SELECT deptid, name, SUM(credits) AS totalcredits FROM department, course GROUP BY deptid, name HAVING deptid = deptno AND totalcredits > 40;
SELECT deptid, name, SUM(credits) AS totalcredits FROM department, course WHERE deptid = deptno GROUP BY deptid, name HAVING totalcredits > 40;
Q100. 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?
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?
- It retrieves students who have not enrolled in all courses offered by department 5.
- It retrieves students who have enrolled in all courses offered by department 5.
- It retrieves students who have enrolled in at least one course offered by department 5.
- It retrieves students for whom there exists at least one course of department 5 that they have not enrolled in.