Toad World® Forums

How to enforce naming conversion in TOAD model designer


#1

Hi,
I am lookout for an option to enforce common naming conversion / style across all the data models in the organization.

For Example: If I have "Last Name” as an Attribute in my Employee entity in my logical model. I wish to convert it into “LastName” without any spaces in my Physical / scripts. Alternative I might wish to have “Last Name” into*“LName”* in my generated script for a specific target database.

Did I miss an option in Toad Data Model or this feature is missing!!!

Thanks,
Subbu


#2

Hello Subbu,

There is not an option to set up how to rename the names during conversion. Nevertheless, feel free to run a script in your PER model and rename the objects at one jump.

Please find attached a sample script that will rename entity names and attribute names.
Run the script in Scripting Window (Tools menu, Expert Mode must be turned on in the Settings menu | Options | General).

Notes on the script:

  1. var Model = app.Models.GetObject(0);
    //… parameter in GetObject determines in which model the script should be executed.
    //0 = first model listed in the Application View, 1 = second model listed in the Application View etc.

EntityNewName = EntityOldName.replace(/ /g,""); //renaming entity
AttributeNewName = AttributeOldName.replace(/ /g,""); //renaming attribute

  • these lines delete the empty spaces in the names.

To rename “Some1 Some2…” to “SSome2…” (- examples), change this line:
EntityNewName = EntityOldName.replace(/ /g,""); //renaming entity

this way:

//rename entity - BEGIN
arrEntity = EntityOldName.match(/(\w)\w+\s+([\w\s]+)/);
if (arrEntity != null)
  EntityNewName = arrEntity[1]+arrEntity[2];
else
  EntityNewName = EntityOldName;
//rename entity - END

And similarly this line:
AttributeNewName = AttributeOldName.replace(/ /g,""); //renaming attribute

this way:

  //rename attribute - BEGIN
  arrAttribute = AttributeOldName.match(/(\w)\w+\s+([\w\s]+)/);
  if (arrAttribute != null)
    AttributeNewName = arrAttribute[1]+arrAttribute[2];
  else
    AttributeNewName = AttributeOldName;
  //rename attribute - END

I attach the possible modifications as well.

If you have any questions, please write us back. Thanks.

Regards,

Vladka + Mario
Renaming_Entities_Attributes.zip (524 Bytes)


#3

Hello Subbu,

There is not an option to set up how to rename the names during conversion. Nevertheless, feel free to run a script in your PER model and rename the objects at one jump.

Please find attached a sample script that will rename entity names and attribute names.
Run the script in Scripting Window (Tools menu, Expert Mode must be turned on in the Settings menu | Options | General).

Notes on the script:

  1. var Model = app.Models.GetObject(0);
    //… parameter in GetObject determines in which model the script should be executed.
    //0 = first model listed in the Application View, 1 = second model listed in the Application View etc.

EntityNewName = EntityOldName.replace(/ /g,""); //renaming entity
AttributeNewName = AttributeOldName.replace(/ /g,""); //renaming attribute

  • these lines delete the empty spaces in the names.

To rename “Some1 Some2…” to “SSome2…” (- examples), change this line:
EntityNewName = EntityOldName.replace(/ /g,""); //renaming entity

this way:

//rename entity - BEGIN
arrEntity = EntityOldName.match(/(\w)\w+\s+([\w\s]+)/);
if (arrEntity != null)
  EntityNewName = arrEntity[1]+arrEntity[2];
else
  EntityNewName = EntityOldName;
//rename entity - END

And similarly this line:
AttributeNewName = AttributeOldName.replace(/ /g,""); //renaming attribute

this way:

  //rename attribute - BEGIN
  arrAttribute = AttributeOldName.match(/(\w)\w+\s+([\w\s]+)/);
  if (arrAttribute != null)
    AttributeNewName = arrAttribute[1]+arrAttribute[2];
  else
    AttributeNewName = AttributeOldName;
  //rename attribute - END

I attach the possible modifications as well.

If you have any questions, please write us back. Thanks.

Regards,

Vladka + Mario
Modifications_Renaming_Entities_Attributes.txt (814 Bytes)


#4

Thanks for the script.

My request looks like a potential enhancement in Toad Model Builder. I have since similar features in other tools. The feature will be useful while designing data model for a complex application or enforcing naming standards across the company.

Thanks,
Subbu


#5

Hi Subbu,

I’ve entered your request to our system. Our developers will consider it. CR # 50 093.

Thanks very much for your co-operation!

Regards,

Vladka