The linking of tables allows detail from more than one table to be used within a Report. Tables are linked by selection of suitable Fields within each table. For example the Forms Table is linked to the Current Pupils table using the 'Code' field in the Forms table and the 'Form code' field held in the 'Current Pupils' table.
Many tables are already linked. The option is however available to manually link together different tables or to amend existing links for an individual Report.
(For further information on Tables and Fields, and the list of Tables which are 'linked',see 'Report Builder - Tables and Fields'.)
'Help' for 'Linking Tables' is divided as follows:
About 'Table Links'
In order to create Reports using data contained in more than one Table (View), it is necessary for a link to be established between the tables. For example if a list of Pupils together with the name of their Form Representative is to be produced, this will require data from both the Current Pupils table and the Forms table. In order that the correct Form Representative is shown against each Pupil, the two tables must be linked using an appropriate field from both tables. A system-defined link exists between the Current Pupils Table and the Forms table. This links uses the 'Code' field in the Forms table and the 'Form Code' field in the Current Pupils table.
Although many links between tables are pre-defined and available by default when creating a Report builder report, it will sometimes be necessary for the user to create or amend the links between tables. Any User defined links will be specific to the individual report in which the links have been defined.
Existing (System-defined) Links
When a Table is selected for inclusion in the report, the system linked Tables will be highlighted in bold.
|
See the applicable help topic from the list below, to view the list of tables and the STANDARD table links available in the selected module:
|
In the example below, the 'Forms' table has been selected (and is displayed in the lower section of the screen). The tables 'Current Pupils', 'Current Pupils All Years', 'Form Years', 'Past Pupils', 'Prospective Pupils' and 'Staff' are highlighted in bold in the upper section of the screen. This means that these tables are already 'linked' to the 'Forms' Table and so no link needs to be manually formed if any of these tables are subsequently selected.
When a linked table is then selected, it is listed in the lower section of the screen with a Join Type of 'Left Outer'. This means that all records within the first selected table will be listed regardless of not there is a link to the second table, but that only those records in the second table which have a link to the first table will be included. In the example below, the Current Pupils table is linked to the Forms table with a 'Left Outer' join. This means that ALL Pupils will be included but only those Forms which are linked to one or more Pupils will be included. For further information on Join Types, see 'Join Types' below.
Creating new Links
The User may link together tables that are not already linked by default so long as he can find one or more suitable fields within each of the Tables for linking together.
Additional fields may also be linked on tables which are already joined.
The example used below is the new linking of the 'Current Pupil Contacts' table to the 'Staff' table with a join type of 'Inner'. The effect of linking these two tables together will be to include data in the report only for those Pupil Contacts who are also members of Staff.
Note: Any manually created Table links will be valid only for the report that is being created.
To create new links:
|
1. |
From either the Query Designer or Query Wizard 'Tables' screen, select the first table for inclusion in the Report. |
|
|
|
|
|
|
|
The selected table will be shown in the lower section of the screen, if using Query Designer:
Or, on the right hand side of the screen, if using Query Wizard:
|
|
|
|
|
|
|
2. |
Select the second table, i.e. the table that is to be linked to the first table. |
|
|
|
|
|
|
|
If the second selected table is not already linked to the first table, the 'Join Table' screen will be given:
In this example, the 'Current Pupil Contacts Table' was selected after first selecting the 'Staff' table. In the upper section of the screen are listed the available fields in each of the selected tables. In the lower 'Joined Fields' section of the screen, where applicable, are suggested links between the two tables.
|
|
|
3. |
Check the 'Join Type' |
|
|
|
|
|
|
|
|
|
|
|
The default link type is 'Inner Join'. This means that only those records which are present in both tables will be included on the report. This may be amended as required - see 'Join Types' below for information on each type of Join available.
|
|
|
4. |
Check the default links |
|
|
|
|
|
|
|
Check the links which have been created by default in the lower 'Joined Fields' section of the screen.
Remove any unwanted links by highlighting the link and selecting
|
|
|
5. |
Add new links as required |
|
|
|
|
|
|
|
To add a new link, select the required field for linking from each Table.
In the above example, the 'Name Id' field has been selected from the 'Current Pupil Contacts' table, and the 'Name Id' field in the 'Staff' table has also been selected. When selections are correct, select
As many links as are required may be entered. It is however only necessary for a single link to be created.
|
|
|
6. |
When all detail is correct, select
|
|
|
|
|
|
|
|
The table link will be shown in the lower section of the screen, if using Query Designer:
Or, on the right hand side of the screen, if using Query Wizard:
|
|
|
7. |
Update the newly entered table links |
|
|
|
|
|
|
|
Update
the table links by selecting
Or,
by selecting
|
|
|
7. |
Viewing/Amending links |
|
|
|
|
|
|
|
See 'Viewing, Adding, Amending and Deleting Links 'below.
|
Viewing, Adding, Amending and Deleting Links
|
1. |
Links between Tables may be viewed, added, amended or deleted from the Query Wizard or the Query Designer 'Tables' screen: |
|
|
|
|
|
Query Designer (i) click on the linked table line:
(ii) Click on the
Query Wizard (i) click on the linked table
(ii)
select
|
|
2. |
The 'Join Table' screen will be displayed: |
|
|
|
|
|
The list of currently joined fields is displayed at the bottom of the screen. These are the existing Table Links. The following options are now available:
|
|
Add a new Link To add a new link, select the required field for linking from each Table.
In the above example, the 'Name Id' field has been selected from the 'Current Pupil Contacts' table, and the 'Name Id' field in the 'Staff' table has also been selected. When selections are correct, select
As many links as are required may be entered. It is however only necessary for a single link to be created. When all required links have been added, select To ensure that amendments are saved, the
|
|
|
Amend an Existing Link To amend a link, the existing link should first be removed (see 'Delete link' below), and the new link then added (see 'Add a new Link' above).
|
|
|
Delete Link To remove a link, highlight
the applicable link in the lower section of the screen, and select
|
|
|
|
When the list of links is as required, select To ensure that amendments are saved, the
|
Join Types
There are four different 'Join types' which may be used when linking fields from different tables together. A summary of each together with an example is shown below. All examples will use the same data to illustrate the difference between the link types.
Inner Join
If an Inner Join is created, then only those records which are present in both tables will be included.
For example If the Prospective Pupil Table and Forms Table are linked using an Inner Join (as above), then (i) only those Prospective Pupils linked to a Form, and (ii) only those Forms linked to one or more Prospective Pupils will be included on the report.
This is illustrated in the example below:
Full Outer Join
If a Full outer Join is created, then all records which are present in both tables will be included.
For example If the Prospective Pupil Table and Forms Table are linked using a Full Outer join (as above), then (i) all Prospective Pupils and (ii) all Forms will be included on the report regardless of whether there is a link between the two.
This is illustrated in the example below:
Left Outer Join
If a Left Outer Join is created, then all records in the first selected table will be included, but only those records in the second table which are linked to one or more records in the first table.
For example If the Prospective Pupil Table and Forms Table are linked using a left Outer Join (as above), then (i) All Prospective Pupils will be included regardless of whether or not they have been allocated a Form, (ii) only those Forms which are held against Prospective Pupils will be included. Any Forms to which no Prospective Pupils have been allocated will not be included on the report.
This is illustrated in the example below:
Right outer Join
If a Right Outer Join is created, then all records in the second selected table will be included, but only those records in the first table which are linked to one or more records in the second table.
For example If the Prospective Pupil Table and Forms Table are linked using a Right Outer Join (as above), then (i) All Forms will be included regardless of whether or not any Prospective Pupils have been allocated to that Form, (ii) only those Prospective Pupils which are held against a Form will be included. Any Prospective Pupils which have not been allocated to a Form, will not be included on the report.
This is illustrated in the example below: