Red Hat Training

A Red Hat training course is available for Red Hat JBoss Data Virtualization

Chapter 10. Creating and Editing Model Objects

10.1. Creating New Model Objects

10.1.1. Creating New Model Objects

This section summarizes Teiid Designer features for creating and editing existing model objects contained in your models. Teiid Designer provides a framework to model various types of metadata. Each metamodel type has a set of parent-child relationships that establish constraints on what can be created and where. You cannot, for example, create a column attribute in a stored procedure, nor can you create a mapping class column in a Web service operation's output message.
The Teiid Designer provides a common set of actions to create new children of these models as well as children of children.
You can create new model objects directly in the Model Explorer view, Diagram Editor or Table Editor using the following actions:
  • New Child Action
  • New Sibling Action
  • New Association Action

10.1.2. New Child Action

To create new child model objects in the Model explorer view:
  1. Select the parent object to which you want to add a child. For example, you can add a package to a package or an attribute to a class.
  2. Right-click on a container object. From the pop-up menu, click New Child. You can now select the child object you would like to add.
    New Child Action In Model Explorer

    Figure 10.1. New Child Action In Model Explorer

  3. The new model object displays on the Model Explorer view and is highlighted for renaming.
    New Model Object In Explorer

    Figure 10.2. New Model Object In Explorer

To create new child model objects in the diagram editor:
  1. Select the parent object to which you want to add a child. For example, you can add a package to a package or an attribute to a class.
  2. Right-click on a container object. From the pop-up menu, click New Child. You can now select the child object you would like to add.
    New Child Action In Diagram

    Figure 10.3. New Child Action In Diagram

  3. The new model object displays on the diagram and is highlighted for renaming.
    New Model Object In Diagram

    Figure 10.4. New Model Object In Diagram

To create new child model objects in the table editor:
  1. Select the row for the parent object to which you want to add a child. For example to add a column, click the Base Table tab and select base table row.
  2. Right-click on a table row. From the pop-up menu, click New Child. You can now select the child object you would like to add.
    New Child Action In Table Editor

    Figure 10.5. New Child Action In Table Editor

  3. The selected tab in the Table Editor changes to the tab for the child object type, the new model object row is displayed and the row's name table cell is highlighted for renaming.

10.1.3. New Sibling Action

To create new sibling model objects in the Model Explorer view:
  1. Select the object to which you want to add a sibling. For example, you can add a column sibling to a column.
  2. Right-click on that object. From the pop-up menu, click New Sibling. You can now select the sibling object you would like to add.
    New Sibling Action In Model Explorer

    Figure 10.6. New Sibling Action In Model Explorer

  3. The new model object displays in the Model Explorer view and is highlighted for renaming.
To create new sibling model objects in the diagram editor:
  1. Select the object to which you want to add a sibling. For example, you can add a column sibling to a column.
  2. Right-click on that object. From the pop-up menu, click New Sibling. You can now select the sibling object you would like to add.
    New Sibling Action In Diagram

    Figure 10.7. New Sibling Action In Diagram

  3. The new model object displays on the diagram and is highlighted for renaming.
To create new sibling model objects in the Table Editor section:
  1. Select the row for the object to which you want to add a sibling. For example, you can add a column sibling to a column.
  2. Right-click on a row. From the pop-up menu, click New Sibling. You can now select the sibling object you would like to add.
    New Sibling Action In Table Editor

    Figure 10.8. New Sibling Action In Table Editor

  3. The selected tab in the Table Editor changes to the tab for the child object type, the new model object row is displayed and the row's name table cell is highlighted for renaming.

10.1.4. New Association Action

To create new associations between model objects in the Model Explorer view:
  1. Select two objects you wish to associate. For example, select columns in different base tables.
  2. Right-click. From the pop-up menu, click New Association > Foreign Key Relationship.
    New Association Action In Model Explorer

    Figure 10.9. New Association Action In Model Explorer

  3. The new relationship link is displayed in the diagram.
    New Association In Diagram

    Figure 10.10. New Association In Diagram

To create new associations between model objects in the diagram editor:
      1. Select two objects you wish to associate. For example, select columns in different base tables.
      2. Right-click. From the pop-up menu, click New Association > Foreign Key Relationship.
      3. The new relationship link is displayed in the diagram. The Column, Foreign Key, Primary Key reference properties are properly set on the selected columns, new primary key and new foreign key.
      1. Select a column in table.
      2. Drag the column to another table and drag over a column and drop onto this column. The target column should highlight in Yellow.
      3. The new relationship link is displayed in the diagram. The Column, Foreign Key, Primary Key reference properties are properly set on the selected columns, new primary key and new foreign key.
To create new associations between model objects in the Table Editor:
  1. Select two objects you wish to associate. For example, select columns in different base tables.
  2. Right-click. From the pop-up menu, select New Association > Foreign Key Relationship.
  3. New Foreign Key and Primary Key objects will be added to the contents of their respective tabs in the Table Editor. The Column, Foreign Key, Primary Key reference properties are properly set on the selected columns, new primary key and new foreign key.

10.1.5. New Model Objects Wizard

Teiid Designer provides New Child and New Sibling wizards for children of view and source relational models,namely tables, views, procedures and indexes.
  • The Create Relational Table Wizard allows you to create a complete relational table including columns, unique keys, foreign keys definition and indexes.

    Note

    Note that the relational view wizard is identical to the relational table wizard.
  • The Create Relational Procedure Wizard allows you to create a complete relational procedure including columns, unique keys, foreign keys definition and indexes. The relational procedure object can represent different types of procedures, including a standard procedure and source function (pushdown function). When the New Child - Procedure... action is launched, the first dialog gives you the option of selecting the procedure type.

    Note

    You can model the user-defined functions in a view model.
    The second dialog in this wizard customizes the Create Relational Procedure dialog based on your selected type.
    Source functions are procedures that are already deployed and accessable on your database. By defining source functions in your relational model, you can call these functions from within your transformation SQL and the functions will be pushed down to your database for execution.
  • Create Relational Index Wizard: Indexes can be created at the same time as your relational table object or via New Child - Index... action and dialog.
  • Create View Model Objects Wizards: For view models, only tables, procedures (standard procedures and user defined functions) and indexes can be created. For view tables and procedures, the primary difference in the wizards is that they include a SQL Transformation tab.
  • Create User Defined Functions Wizard: You can define custom functions as view model procedures of the type "function". When you launch the New Child - Procedure... for a view model, the first dialog gives you the option of selecting the procedure type which includes either a standard view procedure or a user-defined function.
    User Defined Functions require additional properties such as Java Class and Method as well as a path to the jar file containing the code.