Changing a model with the Data Model Editor

You can use the Data Model Editor to change a model. For example, to accommodate new application requirements, you might want to add a new table, change a column in a table, or redefine the partitioning key of a table. The Data Model Editor displays the objects in a model and allows you to edit the objects one at a time, including related objects.
Prerequisites: A model of the object that you want to change must exist.
To edit a model with the Data Model Editor, complete the following steps:
  1. In the Data Project Explorer view, double-click the model that you want to edit. The Data Model Editor opens.

    You can also invoke the Data Model Editor from the Deployment Script Editor. You can only modify the target model. The base model is read-only.

    To open the target model in the Data Model Editor, click the Edit Target Model link on the Data Models page.

    The Data Model Editor has the following characteristics:
    • The left-hand side of the editor displays a Relationships section and the right-hand side of the editor displays a Dependents section. You can type text in the filter fields to filter the lists and quickly move to an object.
    • The Relationships section of the editor shows the objects, by category, that are related to the object that is currently being edited. Each relationship category can be expanded and collapsed.
    • Each object in the Dependents section represents an object in the database. The Data Model Editor lets you edit one object at a time.
    • As you drill down into the database, a breadcrumb trail is displayed.
    • You single-click an object to select it. You can select multiple objects, for example, to copy or delete a group of objects. The currently selected object is highlighted.

      You double-click an object to make it the object that is currently being edited.

      When you click or double-click an object, it becomes the current object in the Properties view.

    • Global edit actions are available from the Edit menu on the main menu bar, and search actions are available from the Search menu.

      You can find and replace objects names in the Data Model Editor by clicking Edit > Find/Replace. You can click Find to cycle the Editor through the matching objects.

      You can use the search capability to find objects across models by selecting Search and then clicking the Data Model Search tab. When you search for the name of an object, the search results are shown in a Search view. You can pin the Search view to the Data Model Editor and then use the up and down arrows in the Search view to cycle the editor through the matching objects.

    • Context-sensitive actions are available by right-clicking an object. When you right-click, a pop-up menu with available actions is displayed. You use the pop-up menu to add new objects to the model.
    • Tools are available from the main tool bar. For example, you can expand or collapse all the Relationship categories at once, sort the Relationship categories and objects alphabetically, and filter the content that is displayed.
    • You can drag and drop objects between the Data Model Editor and other views.
    • You can bookmark objects in the Data Model Editor to facilitate quick access to critical objects through the Bookmarks view.
  2. Use the functionality in the Data Model Editor, the Properties view, and the Outline view to make changes to the model. You can also edit the SQL for the objects to change them.

    You can right-click on objects in the Data Model Editor and select Edit > DDL from the context sensitive menu. This action will generate DDL to create the entire data model. You can change the model by modifying the DDL and then view the changes by comparing your base and target models. The Generate Change Commands wizard enables you to redefine the database object by using CREATE statements. DB2® Change Management Expert will redefine your model according to the modified script.

    Using the Generate Change Commands wizard relieves you of having to keep up with all the new ALTER options. You can focus on the CREATE statements. By using the Generate Change Commands wizard, DB2 Change Management Expert generates the ALTER statements where appropriate. This wizard gives you the benefits of specifying table definitions using DDL, but eliminates the need to remember when to use ALTER and when a DROP or CREATE statement is required.

    The Properties view facilitates editing the attributes of an object. The attributes that are displayed in the Properties view are context sensitive and depend on the type of object that is selected. Changes that are made through the Properties view are reflected immediately in the Data Model Editor, the Outline view, and the Data Project Explorer.

    An Outline view is provided for the Data Model Editor. Context-sensitive actions are available by right-clicking an object in the Outline view. Objects can also be dragged and dropped. You can synch the Outline view with the editor so that the current objects in both are the same.

    Annotations, markers, and decorators are displayed in the editor, the Properties view, and the Outline view to indicate errors.

  3. Click File > Save or press Ctrl + S to save your changes. An asterisk in the tab of the Data Model Editor indicates that a model has unsaved changes. The asterisk disappears when changes are saved.

Example

Assume that you have a model of your HR database and you want add a new index to the EMPLOYEE table and change the data type of the EMPNO column in the table. You can use these steps to make the changes:
  1. In the Data Project Explorer view, double-click your model of the HR database. HR should be displayed in the Data Model Editor.
  2. Double-click HR under Schema.
  3. To add the index:
    1. Right-click the EMPLOYEE table in the Data Model Editor, and click New > Index. An index object is created under the list of Index relationships.
    2. Select the new index object and go to the Properties view.
    3. In the Properties view, use the General tab to rename the index to a meaningful name and the Details tab to define the attributes of and columns for the index.
  4. To change the data type of the EMPNO column:
    1. Double-click the EMPLOYEE table in the Data Model Editor.
    2. Select the EMPNO column and go to the Properties view.
    3. In the Properties view, use the Type tab to change the data type of the EMPNO.
  5. Click File > Save to save the changes that you made.
Restriction: Start of changeThe Outline view fails if the currently selected object is deleted from Edit DDL.End of change
Related concepts
Model comparison and synchronization
Related tasks
Changing a model in the Data Project Explorer view
Changing the diagram of a model
Applying another deployment script to a target model
Applying change commands
Changing preferences for the Data Model Editor
Related information
Merging the structural differences of data objects in the compare editor
Merging data object properties differences in the compare editor


Feedback

Copyright IBM Corporation 2006, 2007. All Rights Reserved.