Display the Oracle Fusion Middleware Online Documentation Library

10-22 Oracle Fusion Middleware Administrators Guide for Oracle Business Intelligence Discoverer 3. Click Yes if you still want to delete the selected joins. What are fan traps, and how does Discoverer handle them? A fan trap is a group of joined database tables that might return unexpected results. The most common manifestation of a fan trap occurs when a master table is joined to two or more detail tables independently. Figure 10–17 A simple fan trap schema Although this construction is relationally correct, you are likely to return incorrect results if you use a straightforward SQL statement to aggregate data points. However, if you use Discoverer to aggregate the data points, Discoverer will never return incorrect results, provided fan trap detection is enabled. Every query that Discoverer generates is interrogated for potential fan traps. If a fan trap is detected, Discoverer can usually rewrite the query using inline views to ensure the aggregation is done at the correct level. Discoverer creates an inline view for each master-detail aggregation, and then combines the results of the outer query. For an example of how Discoverer will return correct results when a straightforward SQL statement will return incorrect results, see Example of a fan trap . In some circumstances, Discoverer will detect a query that involves an unresolvable fan trap schema, as follows: ■ if the detail folders use different keys from the master for the join ■ if there is a direct join relationship between the detail folders thereby creating an ambiguous circular relationship ■ if non-aggregated values are chosen from more than one of the detail folders ■ if more than one detail folder has a separate join relationship to a different master folder In the above circumstances, Discoverer disallows the query and displays an error message. In addition, Discoverer controls which columns can be totalled. If a worksheet displays values of items from both the master folder and the detail folder, Discoverer will not total the values together. Instead, Discoverer will display a null to prevent incorrect or unexpected results. For more information about enabling or disabling fan trap detection in Discoverer, see the Oracle Fusion Middleware Users Guide for Oracle Business Intelligence Discoverer Plus. Example of a fan trap Consider an example fan trap schema that includes a master folder ACCOUNT and two detail folders SALES and BUDGET, as shown below: Creating and Maintaining Joins 10-23 Figure 10–18 Example of a fan trap schema Every account can have several sales figures and several budget figures for each period. Imagine that a Discoverer end user wants to answer the question, What is the total sales and total budget by account?. The aggregates SUM from the two detail tables come from the same master table ACCOUNT. This relatively simply query will produce: ■ correct results if you use Discoverer provided fan trap detection is enabled ■ incorrect results if you use a straightforward SQL statement Producing correct results using Discoverer To answer the question, What is the total sales and total budget by account?, Discoverer: ■ selects the name of the account from ACCOUNT.NAME ■ calculates the sum of SALES from SALES.SALES ■ calculates the sum of BUDGET from BUDGET.BUDGET Discoverer returns correct results, as shown below: Discoverer interrogates the query, detects a fan trap, and rewrites the query to ensure the aggregation is done at the correct level. Discoverer rewrites the query using inline Account Sales Budget Account 1 400 400 Account 2 130 100 Account 3 200 750 Account 4 300 200