QuestionQ61

VerifiedDisplaying Data from Multiple Tables

Refer to the exhibit and review the structures of the product, component, and PDT_COMP tables.

In the product table, PDTNO is the primary key.

In the component table, COMPNO is the primary key.

In the PDT_COMP table, <PDTNO, COMPNO) is the primary key; PDTNO is a foreign key that references PDTNO in the product table, and COMPNO is a foreign key that references COMPNO in the component table.

You want to create a report that lists product names with their corresponding component names, when the component and product names exist.

Evaluate this query:

SQL> SELECT pdtno, pdtname, compno, compname  
FROM product _____________ pdt_comp  
USING (pdtno) ____________ component USING (compno)  
WHERE compname IS NOT NULL;  

Which combination of joins in the blanks produces the correct output?

Question Image

Explanation

A RIGHT OUTER JOIN preserves the rows on its right side, so the product-to-component association rows in PDT_COMP are retained when joined to product. A following LEFT OUTER JOIN preserves that intermediate association result while joining matching component rows. The compname IS NOT NULL predicate retains only rows that have a component name. Oracle documents that right outer joins preserve rows from the right table and left outer joins preserve rows from the left table.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!