PowerDesigner 使用小结

  这里总结一篇关于数据建模工具 PowerDesigner 的使用小技巧,下面列出的两个应用场景要在网上现找解决方案的话还真不必定好找,因此选择将这两个棘手的问题先记下来。数据库

1. PDM 中表间关系出现多引用状况

  这种状况通常是在由 LDM 生成 PDM 时,对于一对一联系,没有指定主从表关系,如图:工具

  

  致使生成的 PDM 中出现一对一关系出现两个引用:spa

  

    若是指定了 Dominant role ,则只会产生一个引用:code

  

  

2. 去外键问题

  默认状况下,经过 PDM 生成数据库初始化脚本时会带有外键生成脚本,以下:blog

  若是在 PDM 的关系属性中将 Generate 后面的钩去掉则可解决(话说这个问题还卡了蛮长时间,最后是一个老工程师指点的)ip

  

3. 在 PDM 中将字段命名格式改为下划线分隔形式

  须要进行操做: Tools -> Excute Commands -> Edit/Run Script , 以下图:ci

  

  选择执行脚本文件: ToLowerCase.vbs :get

  

  

  最后点击 Run 便可,点完不会有任何弹窗予以提示,可直接点击 PDM 中的表查看。这里将 ToLoweCase.vbs 中的代码共享一下:input

Option Explicit
ValidationMode = True
InteractiveMode = im_Batch

Dim mdl ' the current model
Dim i

' get the current active model
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 an Physical Data model."
Else
   ProcessFolder mdl
End If

Private Function ToLowerCase(input)
  Dim result, ch, prevIsUpper
  result = ""
  For i = 1 to Len(input)
    ch = Mid(input, i, 1)
    If Asc(ch) < 91 And Asc(ch) > 64 Then
      If i > 1 And Not prevIsUpper Then
        result = result + "_"        
      End If
      result = result + LCase(ch)
      prevIsUpper = True
    Else
      result = result + ch
      prevIsUpper = False
    End If
  Next
  ToLowerCase = result
End Function

' This routine copies the name into code for each table, column and view
' of the current folder
Private sub ProcessFolder(folder)
   Dim Tab 'running  table
   Dim rc 'return code

   for each Tab in folder.tables
      if not tab.isShortcut then         
         tab.Code = ToLowerCase(tab.Code)
         'output ToLowerCase(tab.Code)
         Dim col ' running column
         for each col in tab.columns            
            col.Code = ToLowerCase(col.Code)
            'output ToLowerCase(col.Code)
         next
      end if
   next
end sub
相关文章
相关标签/搜索