Managing the movie data with Talend MDM - 6.2

Talend MDM Platform Getting Started Guide

EnrichVersion
6.2
EnrichProdName
Talend MDM Platform
task
Administration and Monitoring
Data Governance
Data Quality and Preparation
Installation and Upgrade
EnrichPlatform
Talend Administration Center
Talend CommandLine
Talend DQ Portal
Talend ESB
Talend Installer
Talend MDM Web UI
Talend Runtime
Talend Studio

The example provided in this chapter assumes that:

  • You have launched your Talend Studio and opened the MDM perspective.

  • You have installed all the required third-part libraries and database drivers in your Talend Studio.

In this scenario, you will learn:

Creating a data model

The first step at the beginning of any MDM project involves setting up a data model and creating business entities in this data model. In this example, a Movie data model is created.

Prerequisite: Make sure you have a valid connection to an MDM Server and have created an empty project.

For more information about how to create a connection to the MDM server, see Creating a connection to the MDM server.

  1. In the MDM Repository tree view, right-click Data Model and select New from the contextual menu.

  2. Name your data model Movie, and then click OK.

    In this example, the Create the corresponding Data Container at the same time check box is selected, so that the corresponding data container with the same name will be created.

    A data model and its corresponding data container must have the same name.

In the Studio workspace, an editor opens where you can define the details of your new data model. The new data model and data container are listed in the MDM Repository tree view.

Creating business entities in the data model

The following procedure shows how to populate the Movie data model created in Creating a data model with some business entities.

  1. In the editor, right-click anywhere in the Data Model Entities panel, and then click New Entity.

  2. In the [New Entity] dialog box that opens, enter a name for your new entity in the Name field, Movie in this example.

  3. Select the Complex Type option.

    You use the Simple Type option if you want to define a single element type such as a phone number or an email address, and the Complex Type option if you want to define a more complete structure, such as an address or, in this case, the different attributes that describe a movie.

  4. Leave the other options unchanged and click OK to add your new entity to the editor.

    Each time you create a new business entity, a default Primary Key record, which takes its name from the entity name with the suffix Id, and a Unique Key record which has the same name as the Entity are automatically created. For example, if you create a new business entity and name it Agency, the Primary Key record AgencyId will be created automatically.

  5. Follow the same steps to create a new entity Director.

    The new entity Director is listed in the Data Model Entities panel with a by default attribute DirectorId.

  6. Follow the same steps to create a new entity Customer.

    The new entity Customer is listed in the Data Model Entities panel with a by default attribute CustomerId.

Now three entities Movie, Director and Customer are added to the data model Movie.

Adding attributes to entities

You need to define different attributes for the entities you have just created.

  1. Expand the business entity Movie and anonymous type, right-click the default Primary Key and then click Edit Element in the contextual menu.

  2. Change the name to Id, and then click OK to close the dialog box.

  3. Right-click Id, click Add Element (after) in the contextual menu, and then add each of the following elements with the characteristics shown in the table below.

    In this example, two custom type attributes SourceURL and Rating are added. For more information, see Defining custom type attributes.

    Element type

    Element name

    Minimum occurrence

    Maximum occurrence

    string

    Title

    1

    1

    int

    ReleaseYear

    1

    1

    RatingType (defined custom type)

    Rating

    1

    1

    URL (default custom type)

    SourceURL

    0

    1

    string

    Director

    0

    1

  4. Save your changes.

    A [Validation Result Dialog] dialog box opens to show the validation result.

  5. Click OK to close the dialog box.

  6. In the Director entity, change the name of its default element DirectorId to Id and then add the following attribute:

    Element type

    Element name

    Minimum occurrence

    Maximum occurrence

    string

    Name

    1

    1

  7. In the Customer entity, change the name of the default element CustomerId to Id, and change the type of the default element to a default custom type UUID. For more information, see Defining custom type attributes.

  8. Add the following attributes to the Customer entity.

    In this example, an attribute of anonymous complex type MovieInfo is added. For more information, see Adding complex type attributes.

    Element type

    Element name

    Minimum occurrence

    Maximum occurrence

    string

    FirstName

    1

    1

    string

    LastName

    1

    1

    string

    Gender

    1

    1

    int

    Age

    1

    1

    anonymous complex type

    MovieInfo

    0

    1

In the data model Movie, all the entities Movie, Director and Customer are populated with attributes.

Defining custom type attributes

To define attributes of custom types, you can either change an attribute of simple type to that of a default custom type, or define a new custom type and then use it for the attributes. In this example, two custom type attributes are defined for the Movie entity.

  1. Right-click an attribute of a simple type and then select Change to a Simple Type to open the [Make Simple Type] dialog box where you can select the custom type as needed.

    In this example, select the Custom option, and then select the default custom type URL from the Type list for the SourceURL attribute in the Movie entity.

  2. Click OK to validate your changes.

  3. Define a new custom type and then use it for attributes.

    In this example, to define a custom type RatingType, right-click in the Data Model Types area, and then select Create a Simple Type to open the [New Simple Type] dialog box.

  4. Select the Custom option, and enter a name RatingType in the Type field.

  5. Click OK to close the dialog box.

    The new custom type is created and listed in the Data Model Types area.

  6. In the Data Model Types area, right-click RatingType, and then select Change Base Type to open the [Change Base Type] dialog box.

  7. Select int from the Type list, and click OK to close the dialog box..

  8. To define the minimum value allowed for the custom type, right-click the custom type, select Edit minInclusive from the contextual menu to open the [MinInclusive Facet] dialog box, and then enter a value in the field and click OK to close the dialog box.

    In this example, enter 1.

  9. To define the maximum value allowed for the custom type, right-click the custom type, select Edit maxInclusive from the contextual menu to open the [MaxInclusive Facet] dialog box, and then enter a value in the field and click OK to close the dialog box.

    In this example, enter 9.

    In this example, a custom type RatingType is defined based on the int type with a minimum value of 1 and a maximum value of 9.

  10. In the Movie entity, right-click the attribute Rating, and then select Change to a Simple Type to open the [Make Simple Type] dialog box where you can select the custom type as needed.

    In this example, select the Custom option, and then select RatingType from the Type list for the Rating attribute in the Movie entity.

In the data model Movie, you have defined two custom type attributes SourceURL and Rating for the Movie entity.

Adding complex type attributes

If needed, you can add complex type attributes to an entity. In this example, a complex type attribute MovieInfo is added to the Customer entity created in Creating business entities in the data model.

  1. Expand the business entity Customer and anonymous type, right-click the attribute Age and select Add Element (after) > Add Complex Type Element to open the [Add Complex Type Element] dialog box.

  2. Enter a name for the attribute, MovieInfo in this example, and keep the other options as default.

  3. Click OK to validate your changes.

  4. Expand the MovieInfo attribute and anonymous type, right-click subelement and select Edit Element from the contextual menu.

  5. Change the name to Movie, change the minimum occurrence to 0, the maximum occurrence to Many (leave it blank), and click OK to close the dialog box.

    A [Change to sequence type] dialog box pops up, showing that the Sub-Element Group is changed from All to Sequence. Click OK to close the dialog box.

A complex type attribute MovieInfo is added and listed in the Customer entity, which describes the information of movies rented by the customer.

Defining foreign keys to link entities in a data model

The following procedure shows how to define foreign keys to link entities created in Creating business entities in the data model in the Movie data model.

  1. In the Data Model Entities panel, right-click the element you want to set as a foreign key and select Set the Foreign Key from the contextual menu.

    In this example, right-click the Director attribute from the Movie entity.

    Note that a Foreign Key must always be a string.

    The [Set the Foreign Key] dialog box pops up.