Description:
How can I specify the names of Indexes, so that Primary Key, Foreign Key, etc., have specific names in erwin Data Modeler, after switching to the Physical side of the Model? Currently the Key Group name is used by default and I would like a different naming convention.
Solution:
This can be achieved by implementing the below macro:
1. Go to Tools -> Model Naming Options -> Name Mapping tab and add the macros to convert the Logical names to the Physical format as coded.
2. The following example demonstrates how to have different names for Indexes on the Physical side of the Model.
Use the %Switch command, in the Macro field, of the Name Mapping Tab as shown above. Change the ‘KeyGroup to Index’ macro field from %KeyName to something like the following %Switch syntax:
%Switch(%Substr(%KeyType,1,1))
{
%Choose(P){%TableName_PK}
%Choose(A){%TableName_AK%Substr(%KeyType,3,1)}
%Choose(I){%If(%==(%Substr(%KeyType,2,1),"F")){%TableName_FK%Substr(%KeyType,3
,1)}%else{%TableName_IE%Substr(%KeyType,3,3)}}}
Note: This all needs to be in one line. Yes, it may not show fully in the editor, but as long as it is all there, it will expand as expected.
The above will create a Primary Key Index of TableName_PK, but Alternate Key Index will use Tablename_AK and then the Alternate Key number, like Tablename_AK1. Foreign Key Indexes will have the same name as Alternate Key Indexes, but will have Tablename_FK and Foreign Key number, like Tablename_FK1. The else clause covers the Inversion Entry Indexes and adds on IE and the Inversion Entry number, like Tablename_IE1.
The Substring command can be edited to include other names formats, but this syntax is the basic structure for its use and can be expanded as needed.
Comments
0 comments
Please sign in to leave a comment.