views:

459

answers:

1

In Powerdesign would like to create a VBscript to rename/reform the following names in powerdesigner- Conceptural or Physical model

Alternative/Unique Key Name:

*UQ {table_name} {tablecolumnname}* /////// Example = UQ_Account_AccountNumber

Relationship Name:

FK{table_name}_{reference_table_name}_{reference_column_name}* //////Example = FK_Account_AccountPhone_HomePhoneID

Problem is, how do I get the "table_column_name" and "reference_column_name"?

+1  A: 

Here's something I used to rename the 'friendly' names, plus the constraint names of all my references. Maybe it will help you out.

Option Explicit
ValidationMode  = True
InteractiveMode = im_Batch

Dim mdl 
Set mdl = ActiveModel
If (mdl Is Nothing) Then
   MsgBox "There is no current Model"
ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
   MsgBox "The current model is not a Physical Data model."
Else
   ProcessFolder mdl
End If

Private sub ProcessFolder(folder)
   Dim Tab, Key, Rel
   for each Rel in Folder.References
      Rel.ForeignKeyConstraintName = "FK_" + UCASE(Rel.ParentTable.Name) + "_" + UCASE(Rel.ParentKeyColumnList) + "_" + UCASE(Rel.ChildTable.Name) + "_" + UCASE(Rel.ForeignKeyColumnList)
      Rel.Name = "FK_" + UCASE(Rel.ParentTable.Name) + "_" + UCASE(Rel.ParentKeyColumnList) + "_" + UCASE(Rel.ChildTable.Name) + "_" + UCASE(Rel.ForeignKeyColumnList)
   next
end sub
Zerofiz