Change the Macro to Convert Names

Use a name mapping macro to control how erwin Data Modeler derives physical object names from logical model information. Instead of entering a physical name for each object, you define a naming rule for an object type. For example, the Entity to Table mapping can use %EntityName to derive each table name from its logical entity name.

A macro is an instruction that returns model information or transforms text. When the application evaluates a naming rule, it replaces each macro with its result. A rule can combine macros with literal text, such as an underscore. The rule applies to the selected object type, not to a single object.

Name mapping rules apply to logical/physical models and to logical models used to derive physical models. They do not apply to physical-only models. For the supported mappings and default conventions, refer to the Name Mapping Conventions Using Macros topic.

Find Macro Definitions, Syntax, and Examples

Start with Macro Toolbox to browse the predefined macros by category. Selecting a macro in the toolbox displays its description and an example based on the sample Emovies model. The following reference topics provide definitions, syntax, examples, and the text each macro produces:

  • %EntityName: Returns the logical entity name. Use this as the source for an Entity to Table mapping.
  • %AttName: Returns the current attribute name.
  • %AttDomain: Returns the name of the domain attached to an attribute.
  • %KeyType: Returns the key type, such as PK, AK1, or IE1. Use it as part of a Key Group to Index naming rule.
  • %TableName: Returns the physical table name. You can use it to include the table name in an index naming rule, but not to derive that same table name.

For punctuation and parameter rules, refer to the Macro Syntax topic. Enter macro keywords exactly as documented, including the percent sign (%). To understand the Syntax, Expansion, and Usage sections in each reference topic, refer to the Macro Documentation topic.

Name mapping uses the macros documented under Macro Toolbox. The Template Language and Macro Reference guide describes a separate set of macros used in the Template Editor for forward engineering.

Choose a Naming Rule

Choose macros that return information available for the object type you are mapping. In Entity to Table, the entity is the source and the table name is the result. Use %EntityName, not %TableName, to obtain the source name.

Do not use a self-referencing macro: a rule that reads the name it is trying to generate. For example, %TableName in Entity to Table refers to the resulting table name rather than the source entity name. The application displays a warning for this assignment.

Keep the default macros for logical-to-physical domain conversion and attribute-to-column conversion without rearranging them. For Key Group to Index, you can rearrange the supported macros to match your naming convention.

Examples

  • Entity to Table: Enter %EntityName. For an entity named MOVIE RENTAL RECORD, the macro returns MOVIE RENTAL RECORD. Physical naming options, such as case conversion and special-character handling, determine the final table name.
  • Key Group to Index: Enter X_%TableName_%KeyType. For a table named MOVIE_COPY and a primary key whose type is PK, the rule expands to X_MOVIE_COPY_PK. The X_ and the underscore between the macros are literal text.

For relationship naming examples that combine parent and child names and shorten the result, refer to the Use Macros to Create Logical to Physical Relationship Names topic. Physical names must also conform to the syntax and length limits of the target database.

To change the macro to convert names

  1. On the Toolsmenu of a physical model, click Model Naming Options.

    The Model Naming Options dialog opens.

  2. Click the Name Mapping tab.
  3. In the Macro Namecolumn, click the cell for the object type you want to change, such as Entity to Table.
  4. Enter the macro text directly, or click Macro Toolbox to select a macro, and then click OK.

    The Macro Toolbox lists every macro grouped by object type and, for each one, shows a description and an example based on the sample diagram. It stays open while you edit, so you can try macros as you work.

  5. Click OK to close the Model Naming Options dialog.

    The macro is saved. It is applied the next time physical names are generated—for example, when you derive a model, add a model source, or switch from the logical to the physical model.

To confirm the result, derive or preview the physical model and check that the object names match your naming conventions.

How Glossary Settings and Overrides Affect the Result

The macro supplies the text used for name conversion; it does not define glossary abbreviations. If you enable Use Glossary for an object type, the application uses the active naming standards glossary to translate the terms supplied by the macro. For example, %EntityName supplies the entity-name terms for glossary lookup. Refer to the Apply Naming Standards to a Model topic for instructions on enabling glossary-based conversion.

Macros assigned in the Domain Dictionary override macros on the Name Mapping tab. Manually overridden or hardened physical names also prevent the expected inherited name changes. If a name does not change, check these settings before changing the macro again.

For information about restoring name inheritance, refer to the Reset Physical Model Object Names to Logical Names and Override Name Inheritance topics. Review the scope of a reset before applying it; it can replace existing physical names. Unhardening a name alone does not restore inheritance.