An auto-join
is best explained with a specific example. Suppose you add the following
tables as input to the SQL Join transformation in the following order:
-
CUSTOMER, with the following constraint
defined:
-
INVOICE, with the following constraints
defined:
-
Primary key: INVOICE_NUMBER
-
-
Foreign key: ITEMSINSTOCK
-
PRODUCT, with the following constraint
defined:
-
Primary key: ITEMSINSTOCK
-
ITEMSINSTOCK, with the following
constraint defined:
After
the auto-join process is run for this source data, the process flow
that is depicted in the following display is shown in the
Diagram tab in the
Designer window for the SQL Join transformation.
Sample Process Flow for an Auto-Join Process
This process
flow is resolved to the following order: CUSTOMER, INVOICE, PRODUCT,
and ITEMSINSTOCK. This flow means that the join at the top of diagram
is created first, followed by the join in middle. Finally, the join
at the bottom is created. As each join is created and has its left
and right sides, a matching process is used to determine the best
relationships for the join. The process evaluates the join tables
from the left side to the right side. For example, if a join is connected
on the left, it follows that left side join until all of the tables
are connected to the join. The matching process uses the following
criteria to determine a good match. Note that the tables are removed
from the search process as the relationships are found.
The first
join is created with the left table of CUSTOMER and the right table
of INVOICE. Going through the join relationship process, the key relationship
on CUSTOMER_ID is found between the two tables. Both tables are removed
from the search and the matching process is finished.
The next
join is created with the search results of the CUSTOMER and INVOICE
tables as the new left table and PRODUCT as the right table. A key
relationship between INVOICE and PRODUCT on the column ITEMSINSTOCK
is found, and an expression is created. Both tables are removed from
the search and the matching process is finished.
The last
join is created with the search results of the CUSTOMER, INVOICE,
and PRODUCT table as the new left table and ITEMSINSTOCK as the right
table. No key relationships are found, so the indexes are searched.
A match is found between PRODUCT and INVENTORY on the column ITEMSINSTOCK.
Both tables are then removed from the search and the matching process
is finished.
The relationship
is initialized as follows:
CUSTOMER.CUSTOMER_ID = INVOICE.CUSTOMER_ID and
INVOICE.ITEMSINSTOCK = PRODUCT.ITEMSINSTOCK and
PRODUCT.ITEMSINSTOCK = ITEMSINSTOCK.ITEMSINSTOCK