Join or Merge

Join or Merge task is used to link data with another view based on a column shared between these two views.

join graphic

Fig. 24 Example of a Join

Mammoth provides another function Lookup to achieve similar results. This task is an advanced version of the Lookup.

This is similar to JOIN operation in an SQL database. It is also similar to doing a VLOOKUP in Microsoft Excel.

Quick Start

Let us start with the following two views.

  1. Customers → View 1:
ID Name
1 John
2 Katie
3 Priya
4 Raj
  1. Orders - View 1
ID Customer ID Subtotal Tax Total
1 2 151 15 167
2 1 89 9 98
3 4 89 9 98

Let us associate the customer name with the orders. Note that the customer ID column has corresponding values in Customer → view 1.

In the view Orders - View 1 do the following:

  1. Open Data Preparation menu and click on Merge & Branch Out.
  2. Select Join.
  3. Select the view Customers → View 1.
  4. In select common keys section map Customer ID column to ID column.
  5. Select the type of join.
  6. Select coulmns in the prefix selection box to add a prefix to the column names of Customers View.
  7. Click APPLY.

The following table displays your final result:

ID Customer ID Subtotal Tax Total Customer.Name
1 2 151 15 167 Katie
2 1 89 9 98 John
3 4 89 9 98 Raj

Supported Options

The following options are supported in this task:

  • View to Join with: Allows selecting a view to join with.
  • Common keys: Allows mapping between pairs of columns with common values.
  • Join Type: Allows choosing of one of these four join types: Left, Right, Inner, Outer.
  • Mammoth does not allow certain type of joins. For more information, see Restrictions .

Join Types

Left Join

This option selects all the rows from the current view along with the matching rows from the current view.

Left join graphic

Fig. 25 Left Join

Right Join

This option selects all the rows from the other view along with the matching rows from the current view based on the join key.

Right join graphic

Fig. 26 Right Join

Inner Join

This option selects only matching rows from the current view and the other view where the join condition is met (If at all).

Inner join graphic

Fig. 27 Inner Join

Outer Join

This option selects all the rows from the current view and the other view, regardless of whether the join condition is met or not.”

Outer join graphic

Fig. 28 Outer Join

Restrictions

Mammoth does not allow join rules of cyclic manner, i.e. , If view-1 has a join rule with view-2 then view-2 cannot have a join rule with view-1 (See Fig. 29). It creates a chain of data updates between the views.

cyclic join with 2 views

Fig. 29 If view-1 has a join with view-2 then view-2 cannot join with view-1.

The cyclic behaviour can also occur even when more than two views are involved.(See Fig. 30)

cyclic join with 3 views

Fig. 30 If view-1 has join with view-3 and view-3 has a join with view-2 then view-2 cannot join with view-1.