GATE CSE 2018 Q22: SQL join whose output is a superset of the other joins
- Databases
- 1 mark
- MCQ
- −1/3 if wrong
Syllabus topic: Relational model: relational algebra, tuple calculus and SQL
Question
Consider the following two tables and four queries in SQL.
Book (isbn, bname), Stock (isbn, copies)
(In the paper, isbn is underlined in both tables, i.e. it is the primary key of each.)
Query 1: SELECT B.isbn, S.copies
FROM Book B INNER JOIN Stock S
ON B.isbn = S.isbn;
Query 2: SELECT B.isbn, S.copies
FROM Book B LEFT OUTER JOIN Stock S
ON B.isbn = S.isbn;
Query 3: SELECT B.isbn, S.copies
FROM Book B RIGHT OUTER JOIN Stock S
ON B.isbn = S.isbn;
Query 4: SELECT B.isbn, S.copies
FROM Book B FULL OUTER JOIN Stock S
ON B.isbn = S.isbn;Which one of the queries above is certain to have an output that is a superset of the outputs of the other three queries?
Try it: multiple choice: exactly one correct option
Show answer and explanation
Answer: D (official GATE 2018 final answer key)
Concept used: Full outer join keeps the matched rows (inner join) plus the unmatched rows of both the left and the right table.
First step: Describe which rows each join keeps: matched only, matched plus unmatched left, matched plus unmatched right, or all of these.
Full step-by-step solution
Loading…
Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.
More questions on Relational model: relational algebra, tuple calculus and SQL
Every PYQ on this topic →Share this question
Source: official GATE 2018 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key
More Databases PYQs
- 2026 Session 1 · Q30Which functional dependency inferences always hold
- 2026 Session 1 · Q31Dependency-preserving decompositions for 1NF, 2NF, 3NF, BCNF
- 2026 Session 1 · Q43Relational algebra equivalent of a tuple calculus join query
- 2026 Session 1 · Q65Number of superkeys with candidate keys {A,B} and {A,C}
- 2026 Session 2 · Q15Match DBMS schema levels with what they describe
- 2026 Session 2 · Q20When two transactions do not conflict on a data item