Often users have models that do not contain any comments or definitions. Some reasons why that may occur may be that the database that was Reverse Engineered did not contain any comments or the database itself does not support comments. Whatever the reason, there are many cases in which users would like to add comments and definitions to their existing models.
The most common way to add comments and definitions to a model is to do that manually using the editors in erwin Data Modeler, which can be time consuming. Another way of adding comments and definitions to a model is to use the API. However the difficulty in using the API is that the user also has to write a program. The functionality of automatically adding comments and definitions to a model has now been captured in an easy to use utility and the purpose of this document is to explain what that utility does, and how you can use it.
- Create a simple Logical/Physical model, 'Test' and add Entities and Attributes as follows. Make sure there are no definitions for those objects.
Figure 1. Create a simple Logical/Physical model and add Entities and Attributes.
- Save the model and close it.
- Open the attached Excel file (Definition and Comment Import with datatypes.xls). There are three worksheet tabs. Go to the second tab, 'Entity Definition'. As shown below, that tab contains the columns Entity Name, Entity Definition, and Table Comment.
Figure 2. Open Import Definition.xls and go to the second tab 'Entity Definition'.
- Go to the third tab, 'Attribute Definition'.
As shown below, that tab contains the columns Entity Name, Attribute Name, Attribute Datatype, Attribute Definition, and Column Comment.
Figure 3. Go to the third tab, 'Attribute Definition'.
- Click on the first tab, 'Update ERwin'. That brings up the screen that is shown below.
Figure 4. Click the first tab, 'Update ERwin'.
- Press the button for 'Update Entity/Table Defs/Comments' and you will be asked to select the file that is to be updated. Select the file 'test.erwin' that was created during Step 1 above. That completes the import of the entity definitions to the model.
- Next, if you would like to also import the definitions for the attributes into the model, click the box for 'Update Attribute/Column Defs/Comments'. You can import both entity and attribute definitions by clicking both boxes, one at a time.
Functionalities and Limitations:
- The utility will work in a Logical only or a Logical/Physical model, but not in a Physical only model because the API code was written for logical definitions only.
- The utility creates entities and their attributes when they exist in the Excel file but not in the model. After running the utility, note that an extra entity "Customer" and its attributes along with its definitions appears in the model. That is because that entity and its attributes are defined in the spreadsheet but did not pre-exist in the model.
Figure 5. An extra entity Customer appears in the model.
- If the entity and attribute definitions do not appear in the physical model, there may not be an existing 'link' between the Logical and Physical model. You can get the definitions to appear in the physical model by using the Model Naming Options Reset Names button. To do that, go to Tools | Names | Model Naming Options, select the Name Mapping tab, and then click the Reset Names button.
Figure 6. If the definitions do not appear in the physical model, use the Reset Names button.
In the Globally Reset DBMS Property window, select the checkbox Comment that appears under Select Column Properties to Reset. Doing so will migrate the definitions imported into the Entity and Attributes into the Tables and Columns.
Figure 7. Select the checkbox Comment.
Important: To use the API Excel spreadsheet with 9.64 and above, you must use either erwin Data Modeler 64-bit and Microsoft Excel 64-bit or erwin Data Modeler 32-bit and Microsoft Excel 32-bit. You can't use erwin 64-bit and Microsoft Excel 32-bit.
As you can see, using this utility is much quicker and efficient than the manual method of 'copy and pasting' definitions from Excel to the model in erwin Data Modeler. Moreover, it will also create entities and their attributes if they do not pre-exist in the model while automatically adding their datatypes, definitions and comments. This utility uses the erwin Data Modeler API code which is embedded into the Excel macros. You can review that code to see how it functions.
Definition_Comment_DT_Import_ r73_StringTrimming.xlsm for r7.3 erwin Data Modeler
Definition_Comment_DT_Import_ r81.xlsm for r8.x erwin Data Modeler Definition_Comment_DT_Import_ r9.xlsm for r9.x erwin Data Modeler
All the API worksheets include sample data in the the Entity Definition and Attribute Definition tabs as per the screen shots above. When you go to use the API spreadsheet with you own data, you must remove the sample data first.