RDBMS Questions and Answers – Set Operations

«
»

This set of RDBMS Multiple Choice Questions & Answers (MCQs) focuses on “Set Operations”.

1. What is the function of the union operation?
a) It combines the results of any two different queries
b) It combines the results of two different queries which have the same set of attributes in the select clause
c) It combines the results of two different queries which have the same condition in the where clause
d) It gives the Cartesian product of the results of any 2 queries

Explanation: The union operation combines the results of two different queries which have the same set of attributes in the select clause. It automatically eliminates duplicates.

2. What is the function of the intersect operation?
a) It returns the intersection of the results of the results of any two different queries
b) It returns the intersection of the results of two different queries which have the same set of attributes in the select clause
c) It returns the intersection of the results of two different queries which have the same condition in the where clause
d) None of the mentioned

Explanation: The intersect operation returns the intersection of the results of the results of two different queries which have the same set of attributes in the select clause. It automatically eliminates duplicates.

3. What is the function of the except operation?
a) It excludes all the results present in both the queries
b) It includes the results of the second query but excludes the results of the first query
c) It includes the results of the first query but excludes the results of the second query
d) It includes all the results of both queries but removes duplicates

Explanation: The except operation includes the results of the first query but excludes the results of the second query. It automatically eliminates duplicates but if we want to retain duplicates we must use except all in place of except.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

4. When does the predicate is null succeed?
a) If the value on which it is applied is finite
b) If the value on which it is applied is invalid
c) If the value on which it is applied is blank
d) If the value on which it is applied is more than the allowed limit

Explanation: The is null predicate succeeds when the value on which it is applied is blank/null.

5. Using the _______ clause retains only one copy of identical tuples
a) distinct
b) is not null
c) no repeat
d) from

Explanation: Specifying the distinct clause beside the select clause retains only one copy of identical tuples resulting from the query.

6. Observe the following query and choose the correct option

```SELECT DISTINCT name
FROM student
WHERE ID IS NOT NULL;```

a) The query is syntactically wrong
b) The query gives all the possible student names where a finite value exists for ID
c) The query gives the names of the students that have a null ID and it also excludes identical names
d) The query gives the student names where a finite value exists for ID and it excludes identical names

Explanation: The distinct keyword is used to remove tuples that have identical values. The is not null clause checks only for ID’s that are not null values.

7. What will be the result of the following query?

```(SELECT studentid
FROM student
WHERE SECTION = 'c')
EXCEPT
(SELECT studentid
FROM student
WHERE roll &lt;10);```

a) All the values of the studentid for which section is c and roll < 10
b) All the values of the studentid for which section is c and roll > 10
c) All the values of the studentid for which section not c and roll < 10
d) All the values of the studentid for which section not c and roll > 10

Explanation: The except operation excludes all the tuples that are present in the result of the second query from the result of the first query. It also excludes all duplicates from the relation.

8. Which of the following correctly describes the between predicate in the where clause?
a) It is used to check whether a value is in between two specified values
b) It is used to check whether a value is exactly in the center of the relation alphabetically
c) It is used to check whether a value is in between any two other values in the database
d) None of the mentioned

Explanation: The between predicate in the where clause is used to check whether a value is in between two externally specified values. This clause is used to list out all tuples having a value within a range.

Sanfoundry Global Education & Learning Series – RDBMS.

To practice all areas of RDBMS, here is complete set of 1000+ Multiple Choice Questions and Answers.