Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. What is a subquery?
a) A subquery is a select-from-where expression that is nested within another query
b) A subquery is any query that is nested within another query
c) A subquery is a relation that is externally specified which can be used to handle data in queries
d) A subquery is a condition that excludes all the invalid tuples from the database

View Answer

Answer: a [Reason:] A subquery is a select-from-where expression that is nested within another query. Common uses for sub-queries are to perform tests for set membership, make set comparisons etc.

2. If a set is a collection of values given by the select clause, The ______ connective tests for set membership
a) within
b) include
c) under
d) in

View Answer

Answer: d [Reason:] The in connective is used to test for the membership in a set, where the set is a collection of values given by the select clause.

3. State true or false : Nested Subqueries cannot be used for comparing two different sets
a) True
b) False

View Answer

Answer: b [Reason:] Nested Subqueries can be used for comparing two different sets. Set comparison is an important function of the nested sub-queries.

4. What is the result of the following query?

SELECT studname
FROM college
WHERE marks > SOME (SELECT marks
                                        FROM student
               		    WHERE SECTION = 'c');

a) The query gives all the studnames for which marks are greater than all the students in section c
b) The query gives all the studnames for which the marks are greater than at least on student in section c
c) The query gives all the studnames for which the marks are less than all the students in section c
d) The query is syntactically incorrect

View Answer

Answer: b [Reason:] The “some” comparison is used to check for at least one condition. The > symbol is used to test whether the marks are greater than the right hand side or not.

5. The ________ comparison checker is used to check “each and every” condition
a) all
b) and
c) every
d) each

View Answer

Answer: a [Reason:] The all comparison checker is used to check “each and every” condition. The “each” and “every” comparison checkers do not exist in SQL.

6. The ______ construct returns true if a given tuple is present in the subquery.
a) not exists
b) present
c) not present
d) exists

View Answer

Answer: d [Reason:] The exists construct returns true if a given tuple is present in the subquery. The not exists construct gives true if a given tuple is not present in the subquery.

7. What is a correlated sub-query?
a) An independent query that uses the correlation name of another independent query.
b) A sub-query that uses the correlation name of an outer query
c) A sub-query that substitutes the names of the outer query
d) A sub-query that does not depend on its outer query’s correlation names

View Answer

Answer: b [Reason:] A correlated sub-query is the one that uses the correlation name of an outer query.

8. The _________ construct returns true if the argument in the sub-query is void of duplicates
a) not null
b) not unique
c) unique
d) null

View Answer

Answer: unique [Reason:] The unique construct returns true if the argument in the sub-query is void of duplicates. The not null construct avoids the specification of null values into the attribute.

9. State true or false: We can use Subqueries inside the from clause
a) True
b) False

View Answer

Answer: a [Reason:] SQL allows the use of Subqueries inside the from clause. The subquery used in the from clause must have in its result the attributes that are specified in the select clause.

10. Choose the correct option regarding the following query

WITH max_marks (VALUE) AS
(SELECT MAX(marks)
FROM student)
SELECT studentID
FROM student,max_marks
WHERE student.marks = max_marks.value;

a) The query is syntactically wrong
b) The query gives the studentID of the student with the maximum marks
c) The query gives the maximum marks amongst all the students
d) The query gives all the studentID values except the student with the maximum marks

View Answer

Answer: b [Reason:] The query gives the studentID with the maximum marks because the max(marks) aggregation gives the maximum of the marks.

11. SQL subqueries that can occur wherever a value is permitted provided the subquery gives only one tuple with a single attribute are called _________
a) Exact Subqueries
b) Vector Subqueries
c) Positive Subqueries
d) Scalar Subqueries

View Answer

Answer: d [Reason:] SQL subqueries that can occur wherever a value is permitted provided the subquery gives only one tuple with a single attribute are called Scalar subqueries. Scalar Subqueries can be used in the SQL update statement when they are used under the set clause.