Outer Join Case Study - Teradata Database

SQL Data Manipulation Language

Product
Teradata Database
Release Number
15.00
Language
English (United States)
Last Update
2018-09-28
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata® Database

Outer Join Case Study

Acknowledgement

This case study was originally developed by Rolf Hanusa and is used with his permission. The text has been edited.

Purpose of the Case Study

The outer join is a powerful tool, and its output can be as difficult to interpret as it is to produce. A lack of understanding can produce unexpected, costly, and undesired results. For example, you might erroneously mail promotional fliers to 17 million customers instead of the 17,000 customers that you intended to target.

This case study shows some common pitfalls of the outer join, including how a poorly worded outer join request can result in a simple inner join and how an improperly constructed outer join can return millions of rows that do not answer the business question you are trying to ask.

The study also provides guidelines to help you get a feeling for whether you are answering the business question you think you are asking with your outer joins. The study helps you to understand the complexity of outer joins by using realistic examples and explanations.

As this case study shows, many results are possible, and the correct solution is not necessarily intuitive, especially in a more complex query.

Topics for the Case Study

This case study contains:

  • “Case Study Examples” on page 283
  • “Heuristics for Determining a Reasonable Answer Set” on page 284
  • “First Attempt” on page 285
  • “Second Attempt” on page 288
  • “Third Attempt” on page 290
  • “Final Attempt: The Correct Answer” on page 292
  • “Guidelines for Using Outer Joins” on page 294