Ch 31: SQL Subqueries (Nested & Correlated)

12 Questions12 MCQs0 Short Questions0 Long Questions
๐ŸŽฏ Exam Practice Papers
SEMESTER PASS

CS403 - Database Management Systems Examination Practice

Timed practice exam simulation for CS403 - Database Management Systems.

๐Ÿ“˜ VU MID TERM EXAMLectures 1 to 22
โฑ๏ธ 60 Mins

Mid Term Examination

Covers syllabus of Lectures 1 to 22 with 30 high-yield MCQs in a timed exam environment.

๐Ÿ“30 MCQs
โฑ๏ธ60 Minutes
๐Ÿ“— VU FINAL TERM EXAMLectures 23 to 45
โฑ๏ธ 90 Mins

Final Term Examination

Comprehensive semester exam preparation with 45 MCQs covering Lectures 23 to 45 with complete course coverage.

๐Ÿ“45 MCQs
โฑ๏ธ90 Minutes
Showing 1 โ€“ 10 of 12 Questions
Page 1 of 2
Q1
โ“ MCQ๐Ÿ“˜ CS403๐Ÿ“‘ Lec 31๐Ÿท๏ธ 31.3. Left, Right and Full Outer Joins in SQLMedium๐Ÿ”โญ๐Ÿ’ก๐ŸŒŸ๐Ÿ“„๐ŸŽ“VU๐Ÿ›๏ธVU
Which relational join returns all records when there is a matching key in either the left table (table1) or the right table (table2), filling in NULLs for mismatched rows on both sides?
๐Ÿ’ป sql Snippet
SELECT Teacher.TeacherID, Teacher.Name, Class.ClassID
FROM Teacher
FULL OUTER JOIN Class
ON Teacher.TeacherID = Class.TeacherID;
  1. A.Full outer join
  2. B.Inner join
  3. C.Right outer join
  4. D.Left outer join
Q2
โ“ MCQ๐Ÿ“˜ CS403๐Ÿ“‘ Lec 31๐Ÿท๏ธ 31.2. Inner JoinMedium๐Ÿ”โญ๐Ÿ’ก๐ŸŒŸ๐Ÿ“„๐ŸŽ“VU๐Ÿ›๏ธVU
In which type of relational join are only those rows from two participating tables combined that share matching, identical values in their common join attribute?
๐Ÿ’ป sql Snippet
SELECT * 
FROM Teacher 
INNER JOIN Class 
ON Teacher.TeacherID = Class.TeacherID;
  1. A.Inner join
  2. B.Right outer join
  3. C.Left outer join
  4. D.Full outer join
Q3
โ“ MCQ๐Ÿ“˜ CS403๐Ÿ“‘ Lec 31๐Ÿท๏ธ 31.3. Left, Right and Full Outer Joins in SQLMedium๐Ÿ”โญ๐Ÿ’ก๐ŸŒŸ๐Ÿ“„๐ŸŽ“VU๐Ÿ›๏ธVU
Consider a database with a 'Teacher' table containing 6 rows and a 'Class' table containing 6 rows. When executing a LEFT OUTER JOIN from 'Teacher' to 'Class' on the common 'TeacherID' field, several rows in the final output display 'NULL' values under the class columns (such as ClassID, CourseCode, and DayofWeek). What does a 'NULL' value in these right-table columns signify under Left Outer Join mechanics?
๐Ÿ’ป sql Snippet
SELECT Teacher.TeacherID, Teacher.Name, Class.ClassID, Class.CourseCode
FROM Teacher
LEFT OUTER JOIN Class
ON Teacher.TeacherID = Class.TeacherID;
  1. A.The teacher exists in the database but is not currently assigned to teach any class.
  2. B.There is a syntax error or a foreign key constraint violation in the join query.
  3. C.The corresponding Class records have been permanently deleted from the physical storage.
  4. D.The TeacherID values do not match any compatible database data type in either table.
Q4
โ“ MCQ๐Ÿ“˜ CS403๐Ÿ“‘ Lec 31๐Ÿท๏ธ 31.3. Left, Right and Full Outer Joins in SQLEasy๐Ÿ”โญ๐Ÿ’ก๐Ÿ“„๐ŸŽ“VU๐Ÿ›๏ธVU
Which relational join returns all records from the left table along with only the matching records from the right table, mapping unmatched right-side attributes to NULL?
๐Ÿ’ป sql Snippet
SELECT Teacher.TeacherID, Teacher.Name, Class.ClassID
FROM Teacher
LEFT OUTER JOIN Class
ON Teacher.TeacherID = Class.TeacherID;
  1. A.Left outer join
  2. B.Inner join
  3. C.Right outer join
  4. D.Full outer join
Q5
โ“ MCQ๐Ÿ“˜ CS403๐Ÿ“‘ Lec 31๐Ÿท๏ธ 31.2. Equi-Join and Inner JoinMedium๐Ÿ”โญ๐Ÿ’ก๐ŸŒŸ๐Ÿ“„๐ŸŽ“VU๐Ÿ›๏ธVU
Consider the relations 'Employees' and 'Departments' in an enterprise schema. Write an SQL query to retrieve FirstName, LastName, and DepartmentName for all employees by joining the tables on their shared 'DepartmentID' column.
๐Ÿ’ป sql Snippet
SELECT Employees.FirstName, Employees.LastName, Departments.DepartmentName
FROM Employees
JOIN Departments
ON Employees.DepartmentID = Departments.DepartmentID;
  1. A.SELECT Employees.FirstName, Employees.LastName, Departments.DepartmentName FROM Employees JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID;
  2. B.SELECT Employees.FirstName, Employees.LastName, Departments.DepartmentName FROM Employees LEFT OUTER JOIN Departments ON Employees.DepartmentID!= Departments.DepartmentID;
  3. C.SELECT Employees.FirstName, Employees.LastName, Departments.DepartmentName FROM Employees, Departments WHERE Employees.FirstName = Departments.DepartmentName;
  4. D.SELECT DISTINCT FirstName, LastName, DepartmentName FROM Employees UNION Departments ON Employees.DepartmentID = Departments.DepartmentID;
Q6
โ“ MCQ๐Ÿ“˜ CS403๐Ÿ“‘ Lec 31๐Ÿท๏ธ 31.3. Left, Right and Full Outer Joins in SQLEasy๐Ÿ”โญ๐Ÿ’ก๐Ÿ“„๐ŸŽ“VU๐Ÿ›๏ธVU
Which type of relational join returns all records from the right table along with only the matching records from the left table, mapping unmatched left-side fields to NULL?
๐Ÿ’ป sql Snippet
SELECT Teacher.TeacherID, Teacher.Name, Class.ClassID
FROM Teacher
RIGHT OUTER JOIN Class
ON Teacher.TeacherID = Class.TeacherID;
  1. A.Full outer join
  2. B.Inner join
  3. C.Left outer join
  4. D.Right outer join
Q7
โ“ MCQ๐Ÿ“˜ CS403๐Ÿ“‘ Lec 31๐Ÿท๏ธ 31.5. Self JoinMedium๐Ÿ”โญ๐Ÿ’ก๐ŸŒŸ๐Ÿ“„๐ŸŽ“VU๐Ÿ›๏ธVU
Under standard relational database guidelines, which of the following statements represents a true property and definition of a Self Join operation?
๐Ÿ’ป sql Snippet
SELECT a.stId, a.stName, b.stId, b.stName 
FROM student a, student b 
WHERE a.cr = b.stId;
  1. A.An inner join is performed on two separate physical tables, and then attributes of only one table are retrieved.
  2. B.The left table is joined with the right table on their primary keys, preserving all unmatched records.
  3. C.The right table is joined with the left table using a temporary index on an un-indexed foreign key column.
  4. D.A table is logically joined with itself to resolve unary recursive relationships using table aliases.
Q8
โ“ MCQ๐Ÿ“˜ CS403๐Ÿ“‘ Lec 31๐Ÿท๏ธ 31.4. Self JoinsHard๐Ÿ”โญ๐Ÿ’ก๐ŸŒŸ๐Ÿ“„๐ŸŽ“VU๐Ÿ›๏ธVU
Consider the following SQL statement: ```sql GRANT SELECT, UPDATE(Designation) ON Employee TO Amali, Hiruni WITH GRANT OPTION; ``` What are the exact privileges granted by this statement?
๐Ÿ’ป sql Snippet
GRANT SELECT, UPDATE(Designation) ON Employee TO Amali, Hiruni WITH GRANT OPTION;
  1. A.Grant permission to Amali only to retrieve data from the Employee table, and grant permission to Hiruni only to update the designation from the Employee table.
  2. B.Grant permission to Hiruni in order to grant, select, and update permissions to Amali.
  3. C.Grant permission to both Amali and Hiruni to retrieve data (SELECT) and update the Designation column of employees in the Employee table, with the ability to grant these privileges to other users.
  4. D.Grant permission to Amali and Hiruni to update all data except designation in the Employee table.
Q9
โ“ MCQ๐Ÿ“˜ CS403๐Ÿ“‘ Lec 31๐Ÿท๏ธ 31.2. Equi-Join and Inner JoinMedium๐Ÿ”โญ๐Ÿ’ก๐ŸŒŸ๐Ÿ“„๐ŸŽ“VU๐Ÿ›๏ธVU
Given the relational schema with two tables: 1. 'Teacher' table with attributes: {TeacherID, Name, Office, Phone, Email} 2. 'Class' table with attributes: {ClassID, CourseCode, DayofWeek, StartTime, EndTime, Venue, TeacherID} Write an SQL query to perform an INNER JOIN between these tables to display each teacher's Name alongside their scheduled CourseCode, DayofWeek, and Venue. Show the resulting schema and describe how the database matches records on their common join attribute.
๐Ÿ’ป sql Snippet
SELECT Teacher.Name, Class.CourseCode, Class.DayofWeek, Class.Venue
FROM Teacher
INNER JOIN Class
ON Teacher.TeacherID = Class.TeacherID;
  1. A.SELECT Teacher.Name, Class.CourseCode, Class.DayofWeek, Class.Venue FROM Teacher INNER JOIN Class ON Teacher.TeacherID = Class.TeacherID;
  2. B.SELECT Teacher.Name, Class.CourseCode, Class.DayofWeek, Class.Venue FROM Teacher CROSS JOIN Class WHERE Teacher.Name = Class.Venue;
  3. C.SELECT Teacher.Name, Class.CourseCode, Class.DayofWeek, Class.Venue FROM Teacher LEFT JOIN Class ON Teacher.TeacherID!= Class.TeacherID;
  4. D.SELECT DISTINCT Name, CourseCode, DayofWeek FROM Teacher UNION Class ON TeacherID = TeacherID;
Q10
โ“ MCQ๐Ÿ“˜ CS403๐Ÿ“‘ Lec 31๐Ÿท๏ธ 31.3. Left, Right and Full Outer Joins in SQLHard๐Ÿ”โญ๐Ÿ’ก๐ŸŒŸ๐Ÿ“„๐ŸŽ“VU๐Ÿ›๏ธVU
Analyze the following SQL access control statement: ```sql GRANT SELECT, UPDATE(Designation) ON Employee TO Amali, Hiruni WITH GRANT OPTION; ``` Which of the following is correct regarding the privileges granted by this statement?
๐Ÿ’ป sql Snippet
GRANT SELECT, UPDATE(Designation) ON Employee TO Amali, Hiruni WITH GRANT OPTION;
  1. A.Grants SELECT privilege to Amali only and UPDATE(Designation) privilege to Hiruni only.
  2. B.Grants Hiruni authorization to grant SELECT and UPDATE privileges directly to Amali.
  3. C.Grants SELECT privilege on the entire Employee table, and UPDATE privilege on the Designation column, to both Amali and Hiruni, along with the ability to grant these privileges to others.
  4. D.Grants privileges to both users to update all columns of the Employee table except for the Designation column.