Jump to content
  • This documentation is an older version of JasperReports® Server Data Management Using Domains. View the latest documentation.

    The Joins tab is where you create associations between tables so that you can present them together in the same report. Multiple joins associate columns across many tables to create powerful data visualizations when used in reports. The number and complexity of joins in the Domain depends on your business needs.

    Layout of the Joins Tab

    js-DomainDesigner-joins-tab.png.3526249804fe8127265daad80553766d.png

    Joins in the Domain Designer are grouped in join trees. A join tree is a group of tables that are all connected directly or indirectly through joins. Different join trees have no connections between them. The Joins tab shows tables organized by join tree in the Data Structure panel, and joins organized by join tree in the Design panel. You create joins by dragging fields from the Data Structure panel to the Design panel.

    The Data Structure Panel

    On the Joins tab, the Data Structure panel displays the tables in your Domains, organized into join trees. In this view, a single join tree contains a group of tables that are all connected directly or indirectly through joins. Unjoined tables and columns appear at the top (underneath the data source node), and joined tables and their columns appear at the bottom. The following actions are available:

    Expand the data source node to see the unjoined tables and columns in your Domain.
    Drag the divider between the data source tables and the join trees to adjust the viewable area.
    Expand a join tree to see the tables it contains.
    Expand a table or derived table to see the columns it contains.
    Drag a column to the Joins design panel to use it in a join.
    Right-click the data source node to display a context menu with the following choices:
         Generate Joins – Automatically creates joins based on foreign keys. If the database does not have foreign keys, you see an error and no joins are generated.
    Right-click a join tree to display a context menu with the following choices:
         Create Calculated Field – Opens the Calculated Field dialog box to create a calculated field using columns from the tables in the join. See Calculated Fields for more information.
    Right-click a table to display a context-sensitive menu that includes some of the following:
         Copy Table – Copies the selected table and gives it a name with sequential numbering.
         Rename Table – Changes the name of the selected table. The new name becomes the ID of the table throughout the Domain, and is updated everywhere it appears in the Domain Designer.
         Remove Table – (Copy of table only.) Removes the selected table copy from the Domain. To remove the original table from the Domain, use the Data Management tab.
         Edit Derived Table… – (Derived table only.) Opens the Edit Derived Table dialog, where you can change the table name, query, and selected fields. If you change the name, the new name becomes the ID of the table throughout the Domain and is updated everywhere it appears in the Domain Designer.
         Remove Derived Table… – (Derived table only.) Removes the selected derived table from the Domain.
         Always Include Table – (Table in a join tree only; not available for unjoined tables.) Includes this table in all Ad Hoc views that use this join tree, even if the table is not explicitly added by the Ad Hoc user. Enable Use Minimum Path Joins when you select this option. See Prioritizing Joins for more information.
         Create Calculated Field – Opens the Calculated Field dialog box to create a calculated field using the columns in the table. See Calculated Fields for more information.
    Hover over a table or table copy to see the name of the original table in the data source.

    The Joins Design Panel

    The Joins design panel shows the join trees and joins you have added to your Domain.

    Working With Join Trees

    In the Joins panel, the join trees in your Domain appear as containers with individual joins inside them. The selected join options are displayed for each join. For more information about the many possible join operations, see Advanced Joins.

    A join tree with multiple joins

    js-DomainDesigner-join-tree.png.422f369bf6a78b60a1ae571f2fcbbde7.png

    The join tree title bar at the top of each join tree lets you perform the following actions:

    js-DomainDesigner-icon-drag-join-tree.png.f46f64c53d5a59b4d47d0dacd05ada8f.png
    js-DomainDesigner-icon-join-collapsed-arrow.png.4a59393a75112938ef76a861372ffe67.png
    Type, Weight – Read-only headings that refer to properties of the individual joins in the join tree.
    js-DomainDesigner-icon-kebab.png.18d2ef8e564d17e8fc146dadb683c650.png
         Rename Join Tree – Displays the Rename Join Tree dialog, where you can give your join a more useful name.
         Use Minimum Path Joins – Helps you choose how joins are chosen in Ad Hoc views. Deselected by default; it is good practice to select this. See Prioritizing Joins for more information.
         Use all joins – Forces an Ad Hoc view to include all joins in the join tree. Included for backwards compatibility. Unless you have specific need for it, it is good practice to leave this option unselected. See Prioritizing Joins for more information.
    js-DomainDesigner-icon-remove.png.e80ec18f0ff699e2a69e4ca433bb1263.png

    Working with Joins

    Individual joins appear in their join tree container. A join includes a title bar and entries for the joined columns.

    A Single Join Between Two Tables

    js-DomainDesigner-join-simple.png.50a8246676b8de91600f3262c001e014.png

    If you create multiple joins between the same two tables, the new join component is added to the existing join. See Composite Joins for more information.

    Multiple Joins For the Same Two Tables

    js-DomainDesigner-CompositeJoin-Example.png.46d1190e20e5d235538190e5e56057e4.png

    The join title bar at the top of each join includes the following:

    js-DomainDesigner-icon-join-collapsed-arrow.png.88bc2a8d8d9a45118f222d1693e8318f.png
    Left column name (read-only) – Displays the table used in the left side of the join.
    Join icon
    Right column name (read-only) – Displays the table used in the right side of the join.
    Type drop-down – Sets the type of your join: Inner, Left Outer, Right Outer, or Full Outer. See Join Type.

    note-icon-ns.png.543d6eac43c66e5b0041f3046da46cbe.png

    Full Outer is not supported for MySQL databases.

    Weight drop-down (default = 1) – Influences which joins are used in an Ad Hoc view. Higher weights indicate less desirable joins. To change this value, you must enable Use minimum path joins for this join tree. See Join Weights for more information.
    js-DomainDesigner-icon-kebab.png.fef6055fce1796f0697117dd60b4b1e3.png
    js-DomainDesigner-icon-remove.png.2d555ea87fcecead801ff547946abfee.png

    The entry for each component displays the following:

    Left column name (read-only) – Displays the table and column for the left side of the join.
    Join comparison menu – Drop-down that lets you select a comparison operator, based on the type of the join. Operators include =, ≠, >, <, >=, and <=.

    warning-icon-ns_28x28.png.be20edbf73cfdfdb50de654863e13cb3.png

    Comparison operators other than = (such as ≠, >, <, >=, <= ) generate a large amount of rows (similar to a Cartesian product) when used on their own. Best practice is to use them as constraints in conjunction with a = join on the same pair of tables. See Comparison Operators for more information.

    Right column name (read-only) – Displays the table and column for the right side of the join. For a custom join, displays the constant.
    js-DomainDesigner-icon-kebab.png.74f533c07602b4fce0e9df9337377a1f.png
    js-DomainDesigner-icon-remove.png.13b80fc978b0b6f09c16bb1b372fd909.png

    Creating a Join

    1. In the Data Structure panel, find the column you want to use for the left-hand side of your join and drag it into the Design panel in the location you want:
         To create a new join on an empty canvas, drag the column anywhere on the Design panel. A new join is created, along with the join tree that contains it.
         To add a new join tree when join trees are already present, drag the column to a blank space above, between, or below the existing join trees. The target area is highlighted with a thick blue line.
         To add a join to an existing join tree, drag the column to the join tree. The target join tree is outlined with a dashed line to show it is selected.

    A join is added to the Design panel. The column you dragged is added on the left, and the Drag a field here is displayed on the right.

    Creating a New Join

    js-DomainDesigner-create-join-left.png.687e1ef27beb30340368157babe376a4.png

    2. Select the join type (Inner, Left Outer, Right Outer, Full Outer) you want from the Type menu. This can be changed later. See Join Type for more information.
    3. Drag the column for the right table to the Drag a field here box. Make sure to choose a column that's compatible with the column you already chose. The column is added to the join.

    Adding the Right Table to a Join

    js-DomainDesigner-create-join-right.png.ebba455b82364102c64a51188cd2babe.png

    4. If you want to change the comparison operator for the join, select a different operator from the list. The list of available operators depends on the column type.

    warning-icon-ns_28x28.png.33740f31524a52624012859a77f9d70b.png

    Comparison operators other than = (such as ≠, >, <, >=, <= ) generate a large amount of rows (similar to a Cartesian product) when used on their own. Best practice is to use them in conjunction with a = join on the same pair of tables. See Comparison Operators for more information.

    5. If you want to add a weight to the join, first make sure that Use minimum path joins is selected in the join tree settings. Then select the weight you want from the Weight menu. Remember that a higher weight means a less desirable join. See Join Weights for more information.


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...