Toad World® Forums

How to transform logical to physical model and generate DDL

I've constructed a logical model with Entity and Attribute names like:
"Table Name One"."This is the first attribute" ...

I would like to transform these names to a physical model with names like:
"TABLE_NAME_ONE"."THIS_IS_THE_FIRST_ATTRIBUTE".

I don't see a way to convert spaces to underscores, or to automatically convert to upper case. I have found the transformation to a physical model (I selected SQL Server 2014), but there is conversion or type change that occurs during the conversion. How do I do this?

Thank you,
Jerry

Hi Jerry,
if you would like to have spaces in name, you can use normal physical model and insert this value to Caption and in Name you will store physical name without spaces. So first step for you is convert your logical model to SQL Server 2014 or other db oriented model. You get physical model, but still with spaces in names.


Second step is define Naming Convention. Please Open Model Properties Dialog, click on tab Naming Convention and choose Manage Naming Convention.

Create New Naming Convention and Edit it.
Go to Glossary tab, and define character replacement set. In this set we just replace space with underscore.
image
Go to Naming Convention Rules tab and select Entities, Attributes, or other objects. All Apply and assign this Naming Convention to model.
image
From this point when you add new attribute and you will insert caption with spaces it will be automatically change to underscores in Name. For Already existed spaces in Name please go to main menu-Tools-Naming Convention-Verification...

Just select what you want to change (probably all) and press update.

Petr

1 Like

Petr,

Thank you! That worked, I appreciate your detailed assistance!

Yours truly,
Jerry

Another way to do this is in the Naming Convention Rules tab itself, where there is a 'Replacer' column in which you can specify a substitute character for an invalid character. Hit F2 to edit the Replacer field and add the Underscore. You then have to deselect 'Space (32)' as a valid character. This has the added functionality that anything that isn't a valid character (e.g. question marks, colons, exclaimation marks, etc) also gets replaced by an underscore. This may be good or bad, depending on your requirements. You can also use different replacement characters for different Object Types, where as the other option applies across all Object Types chosen.

Hope this helps.

1 Like

Thank you for the complementary answer, Robert.