Scenario: Inserting data in parent/child tables - 6.1

Talend Components Reference Guide

EnrichVersion
6.1
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

The following Job is dedicated to advanced database users, who want to carry out multiple table insertions using a parent table Table1 to generate two child tables: Name and Birthday.

  • In Access 2007, create an Access database named Database1.

  • Once the Access database is created, create a table named Table1 with two column headings: Name and Birthday.

Back into the Integration perspective of Talend Studio, the Job requires twelve components including tAccessConnection, tAccessCommit, tAccessInput, tAccessOutput and tAccessClose.

  • Drop the following components from the Palette to the design workspace: tFileList, tFileInputDelimited, tMap, tAccessOutput (two), tAccessInput (two), tAccessCommit, tAccessClose and tLogRow (x2).

  • Connect the tFileList component to the input file component using an Iterate link. Thus, the name of the file to be processed will be dynamically filled in from the tFileList directory using a global variable.

  • Connect the tFileInputDelimited component to the tMap component and dispatch the flow between the two output Access components. Use a Row link for each of these connections representing the main data flow.

  • Set the tFileList component properties, such as the directory where files will be fetched from.

  • Add a tAccessConnection component and connect it to the starter component of this Job. In this example, the tFileList component uses an OnComponentOk link to define the execution order.

  • In the tAccessConnection Component view, set the connection details manually or fetch them from the Repository if you centrally store them as a Metadata DB connection entry. For more information about Metadata, see Talend Studio User Guide.

  • In the tFileInputDelimited component's Basic settings view, press Ctrl+Space bar to access the variable list. Set the File Name field to the global variable: tFileList_1.CURRENT_FILEPATH. For more information about using variables, see Talend Studio User Guide.

  • Set the rest of the fields as usual, defining the row and field separators according to your file structure.

  • Then set the schema manually through the [Edit schema] dialog box or select the schema from the Repository. Make sure the data type is correctly set, in accordance with the nature of the data processed.

  • In the tMap Output area, add two output tables, one called Name for the Name table, the second called Birthday, for the Birthday table. For more information about the tMap component, see Talend Studio User Guide.

  • Drag the Name column from the Input area, and drop it to the Name table.

  • Drag the Birthday column from the Input area, and drop it to the Birthday table.

  • Then connect the output row links to distribute the flow correctly to the relevant DB output components.

  • In each of the tAccessOutput components' Basic settings view, select the Use an existing connection check box to retrieve the tAccessConnection details.

  • Set the Table name making sure it corresponds to the correct table, in this example either Name or Birthday.

  • There is no action on the table as they are already created.

  • Select Insert as Action on data for both output components.

  • Click on Sync columns to retrieve the schema set in the tMap.

  • Then connect the first tAccessOutput component to the first tAccessInput component using an OnComponentOk link.

  • In each of the tAccessInput components' Basic settings view, select the Use an existing connection check box to retrieve the distributed data flow. Then set the schema manually through [Edit schema] dialog box.

  • Then set the Table Name accordingly. In tAccessInput_1, this will be Name.

  • Click on the Guess Query.

  • Connect each tAccessInput component to tLogRow component with a Row > Main link. In each of the tLogRow components' basic settings view, select Table in the Mode field.

  • Add the tAccessCommit component below the tFileList component in the design workspace and connect them together using an OnComponentOk link in order to terminate the Job with the transaction commit.

  • In the basic settings view of tAccessCommit component and from the Component list, select the connection to be used, tAccessConnection_1 in this scenario.

  • Save your Job and press F6 to execute it.

The parent table Table1 is reused to generate the Name table and Birthday table.