| Oracle Discoverer Administration Edition Administration Guide Release 4.1 for Windows A86730-01 |
|
This chapter consists of the following sections:
In Discoverer, a Join relates two folders using one or more common items. This is similar to a Join in the database which relates two tables using common columns.
The Joins you create in Discoverer Administration Edition affect the combinations of items that can be selected during the following operations:
If you select an Item, during either of these operations, you can then only select Items from Folders joined to the Folder containing the selected Item. If one or more Items from these Folders are selected then further joined Folders become available.
Joins are defined with a master and detail end. The master end is the folder that has one row, for which there are several detail rows. For example, the relationship of a master row in the Department folder to the many detail rows in the Employee folder.
It is important to make sure you define the Join with the correct folders at the master and detail ends. If you set up this relationship incorrectly, it adversely affects what combinations of folders a user can combine in a single query, which in cases of queries with three or more folders can, in some circumstances, lead to misleading or incorrect results. It can also affect whether summary tables can be used to speed up queries.
Usually joins are one-to-many, where one row in the master folder is joined to multiple rows in the detail folder.
Occasionally there are one-to-one and many-to-many joins. Many-to-many joins are not supported directly in Discoverer, or in any relational system, although they can always be worked to be transformed to multiple many-to-one joins.
Users of Discoverer Plus cannot set up their own join conditions. However, they can decide which join path to use if more than one join exists.
This section describes how to create Joins. If you have already created a Join in the tutorial, you are familiar with the Join dialog boxes and have seen how they create Complex Folders from which an end user can access useful combinations of data.
Creating a Join starts with either selecting the Item that will be the Master Item, or the Folder it belongs to. If you choose Insert | Join before selecting an Item or Folder, a selection dialog box opens for selecting the Item that will be the Master Item.
If you did not select the Master Item in step 1, the first New Join dialog box opens (see Figure 11-1). Select the Folder that contains the Item that you want to be the Master Item and click OK.
This opens the main New Join dialog box (see Figure 11-2). The Master Item is displayed in the Master Folder column.
Operator-- use the drop-down list to select an operator for the type of join you want to create. Section 11.1, "Introduction." describes the different types of Joins. Operators include:
|
= |
equijoin, combining rows that have equivalent values for specified items |
|
< > |
not equal |
|
< |
less than |
|
<= |
less than or equal |
|
>= |
greater than or equal |
|
> |
greater than |
Detail Items--select the folder that contains the detail item from the drop-down list. The detail item can be in a folder in either the same business area as the master item, or in a folder in a different business area. The syntax for the value in Detail Items is folder name.item name.
Name--name the join you are creating.
Description--text field for describing the join you are creating.
Multi-item--replaces the New Join dialog with a New Multi-item Join dialog with room for multiple rows of join criteria, which can be added and deleted using the Add and Delete buttons (Figure 11-4).
Options--displays a dialog box for defining outer join conditions (Figure 11-3).
This dialog presents the following options:
Outer join on detail--creates an outer join. Returns all master rows that have no corresponding detail items, plus all matching master and detail rows.
Outer join on master--creates an outer join. Returns all detail rows that have no corresponding master, plus all matching detail and master rows.
|
NOTE: This construct is fairly rare in real schemas. It requires the Detail foreign key can have null values option, described next. |
Detail foreign key can have null values--this setting should only be used on rare occasions, and only affects a particular aspect of when summary tables are used to satisfy a query. Foreign keys usually have values and, in most cases, they are mandatory columns in the database. Such joins are sometimes described as lossless joins.
This setting is required if you are setting detail rows that have no master, because it implies that the foreign key column will contain some null values. On its own, it has no effect on SQL generation, but is required to determine when Discoverer can use summary tables in some special circumstances. For example,
If Detail foreign key can have null values is not set, this query uses the summary table. This is this setting's only effect.
One to one join relationship between master and detail--creates a one-to-one relationship instead of a one-to-many relationship between the master and detail tables. There is no real master and detail in this case, because there is only one row in each. These joins are unusual, but do occur in schemas occasionally.
This setting has no effect on the SQL that Discoverer generates, because SQL does not know about the cardinality of joins. It only affects the fan trap detection described in Section 11.6, "Fan Traps."
Because true one-to-one joins do not result in Cartesian products, it is possible to query a master with multiple detail folders, provided that all but one of the detail folders are joined with one-to-one joins. If these were all one-to-many joins, making it possible for a row in one detail table to join to many rows in another detail table, and vice versa, the result is a Cartesian product. Cartesian products are explicitly disallowed in Discoverer, because they are almost never the desired or expected result.
The New Join dialog opens when you do one of the following:
Use the New Join dialog as follows:
Use the pull-down list if you want to specify a different item in the same folder.
Click the item to be used as the master item.
In this new dialog, select the folder and the detail item for the join. You can choose a detail item from another open business area.
If you want to create multi-item joins, click the Multi-item button and go to Section 11.2.2, "Creating Multi-item Joins."
The New Join dialog closes and the join is added to the folder, with an icon next to it indicating the join relationship.
For information about editing joins, read Section 11.4, "Editing Joins."
The join feature includes the option of adding multi-item joins. Click the Multi-item button to open the New Multi-Item Join dialog. Use this dialog to add items to the join between folders.
In a multi-item join, all master items must belong to one folder and all detail items must belong to one folder. If you add a master or detail item from a different folder, all items from the previous folder will be deleted from the join.
When you have completed selecting items in this row, the Add button reactivates, ready to add another row.
Join properties are accessible through Join Properties dialog boxes. This section shows you how to edit Join properties. Figure 11-5 shows an example Join Properties dialog box.
This section describes how to edit a Join's properties.
There are four ways to do this:
For more information on the fields on this dialog box, click Help.
The following steps show you how to set common properties for more than one Join at a time:
There are three ways to do this:
All properties that are common to each of the selected Joins are displayed. If the data for a field is not common to each of the selected Joins, the field is blank.
For more information on the fields on this dialog box, click Help.
This section describes how to edit an existing Join.
There are three ways to do this:
The Edit Join dialog box works in the same way as the New Join dialog box (see Section 11.2.1, "Using the New Join Dialog" for more information).
This section describes how to delete Joins.
To select more than one Join at once, hold down Ctrl while you click on the Joins.
There are three ways to do this:
This opens the Confirm Delete dialog box.
Occasionally you set up joins that include a master with two separately joined detail folders, such as pictured in Figure 11-8. This situation is referred to as a fan trap.

As an example, the fan trap schema in Figure 11-8 includes a master folder (ACCOUNT) and two detail folders (SALES and BUDGET). An account can have several sales and several budget figures for each period. In most cases Discoverer can resolve queries involving fan trap schemas to give the correct results. For example, consider the following rows:
| ACCOUNT | |
|---|---|
| ID | Name |
|
1 |
Account 1 |
|
2 |
Account 2 |
|
3 |
Account 3 |
|
4 |
Account 4 |
| BUDGET | ||
|---|---|---|
| Accid | Budget | Period |
|
1 |
200 |
1 |
|
1 |
200 |
2 |
|
2 |
100 |
3 |
|
3 |
150 |
2 |
|
3 |
250 |
3 |
|
3 |
350 |
4 |
|
4 |
100 |
1 |
|
4 |
100 |
2 |
| SALES | ||
|---|---|---|
| Accid | Sales | Period |
|
1 |
100 |
1 |
|
1 |
100 |
2 |
|
1 |
200 |
3 |
|
2 |
50 |
1 |
|
2 |
80 |
2 |
|
3 |
200 |
3 |
|
4 |
150 |
2 |
|
4 |
50 |
3 |
|
4 |
100 |
4 |
If the user selects ACCOUNT name, sum of SALES and sum of BUDGET in a query they will see the following results:
| Account | Sales | Budget |
|---|---|---|
|
Account 1 |
400 |
400 |
|
Account 2 |
130 |
100 |
|
Account 3 |
200 |
750 |
|
Account 4 |
300 |
200 |
However there are situations where Discoverer prevents queries involving fan trap schemas from returning the expected results. In these cases, Discoverer disallows the query and displays an error message. Such situations arise in any of the following circumstances:
If you are setting up a fan trap join configuration inside a Complex Folder, to guarantee that correct results are returned, be sure to specify the aggregates to use for the details by editing the Item properties and setting the formula (for example SUM(Sales Fact.Sales)).
|
|
![]() Copyright © 2000 Oracle Corporation. All Rights Reserved. |
|