How to set Max Table Name Length to 30 characters in TDM 5.4.6.12

Hello,

I have created a Data Model for MySQL 5.6. There are about 200 odd tables. I would like to know to how to create a constraint or set a constraint for Max Table Name Length should not exceed 30 characters in TDM 5.4.6.12.

Thank You.

Hello Abhishek,

TDM is capable of creating constraints, but their code has to be written manually in the SQL tab. If I’m not mistaken, MySQL does not have this sort of check constraint, so TDM cannot help you in this regard.

You could theoretically create a macro to display/truncate entity names exceeding 30 characters. It has a disadvantage though - you would need to run it manually every now and then. If you’d like, I could create a sample macro/script for you.

Regards,

Lukas

Hello Lukas,

Thank you for your reply…

My basic intention is…I am creating a data model which should support both MySQL and Oracle as well. So while creating entities I wanted to make sure that whenever I name an entity, it should not exceed more than 30 characters.

I have noticed that when I do model verification, it does check Max Name Length for MySQL Model. I would like to know where is this check is configured in TDM.

And Yes…I really appreciate if you could create a macro/script for this purpose.

Unfortunately, the verification rule cannot be modified by users, specific rules can be only enabled/disabled.

Here are two scripts, simply choose one and run it in Expert Mode Menu | Scripting Window (you might want to create a backup of your model if you choose the truncating script).

This script lists all entity names that are too long in Message Explorer:

function main(){
var e, iterEntity;
Model.Lock();

 Log.Information("The following entities exceed 30 characters");
 for (e=0; e<Model.Entities.Count; e++)  
 {
     iterEntity = Model.Entities.GetObject(e);
     if (iterEntity.Name.length > 30)
     {
        Log.Information(iterEntity.Name);
     }    
 }
 Model.UnLock();

}


Or you can use this script which outright truncates entity names that are too long and lists all the changes (also in Message Explorer).

function main(){
var e, iterEntity, origEntityName, truncatedEntityName;
Model.Lock();

 for (e=0; e<Model.Entities.Count; e++)  
 {
     iterEntity = Model.Entities.GetObject(e);
     if (iterEntity.Name.length > 30)
     {  
        origEntityName = iterEntity.Name;
        truncatedEntityName = iterEntity.Name.substring(0,31);
        iterEntity.Name = truncatedEntityName;
        Log.Information("Truncated: " + origEntityName + " >>> " + iterEntity.Name);
     }    
 }
 Model.UnLock();

}

You can further customize the script based on these samples, of course. Also, note that the scripts work with entities physical Name, not Caption.

Regards,

Lukas

Hello Lukas,

Really appreciate your response and for the code…Will try this and see…