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
View Answer

Answer: b
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.
advertisement

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
View Answer

Answer: b
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
View Answer

Answer: c
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.

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
View Answer

Answer: c
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
View Answer

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

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
View Answer

Answer: d
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?

advertisement
(SELECT studentid
FROM student 
WHERE SECTION = 'c')
EXCEPT
(SELECT studentid
FROM student
WHERE roll <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
View Answer

Answer: b
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
View Answer

Answer: a
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.

advertisement

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

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn