中纺cbd商业中心:[转]PowerDesigner使用技巧

来源:百度文库 编辑:中财网 时间:2024/04/29 07:13:19

使用经验:

1、pd中复制一列是,实际上是一个链接。源列的变动同时体现在复制列上

2、数据库设计通常步骤:CDM缺定主要结构--》生成PDM--》在PDM上修改,必要时生成CDM

     若由pdm生成cdm再生成pdm,在pdm中修改过的外键名将被改回到默认值

3、必要时可以通过修改模板(Database-Edit Current DataBase)改变脚本的格式。

     例如:

           Script-Objects-Column-Add的Value中开头增加一行“--%COLNNAME%”以便在脚本中显示列的中英文对照

4、去掉讨厌的name、code映射:Tools-General Options-clear the Name to Code mirroring check box

5、对于大小写不敏感的数据库(如Oracle),PowerDesign在创建脚本时自动给表名和字段名加上双引号,以“强字符串”形式来获 取区分大小写,这样给sql语句的编写制造很多麻烦。

     去掉这个添足的功能:

      Database -〉Edit Current DBMS -〉Script -〉Sql -〉Format -〉CaseSensitivityUsingQuote右边面板参数值 Value 选择No

6、由cdm生成pdm,可以控制是否将关系生成引用;由pdm生成脚本,可以控制是否将引用生成外键

7、对于oracle而言,为表设置选项(如tablespace GPSSYSTEM)可使其创建到正确的表空间;为主键设置选项(using index tablespace GPSINDEX)使索引创建到正确的表空间中

8、使数据模型图上显示中文:Tools-Model Options-Naming Convertion,在右侧Display处选择Name

9、建立一个表后,为何检测出现Existence of index的警告

      A table should contain at least one column, one index, one key, and one reference.

      可以不检查 Existence of index 这项,也就没有这个警告错误了!

      意思是说没有给表建立索引,而一个表一般至少要有一个索引,这是一个警告,不用管也没有关系!

10、创建一个表在修改字段的时候,一修改name的内容,code也跟着变化,如何让code不随着name变化

Name和Code 的右侧都有一个按钮“=”,如果需要不同步的话,把这个按钮弹起来就可以了。

Tools->General Options->Dialog->Name to Code Mirroring (去掉)

11、由pdm生成建表脚本时,字段超过15字符就发生错误(oracle)

     原因未知,解决办法是打开PDM后,会出现Database的菜单栏,进入Database - Edit Current DBMS -script-objects-column-maxlen,把value值调大(原为30),比如改成60。出现表或者其它对象的长度也有这种错误的话都可以选择对应的objects照此种方法更改!

或者使用下面的这种方法:

     生成建表脚本时会弹出Database generation提示框:把options - check model的小勾给去掉,就是不进行检查(不推荐)!

    或者可以修改C:\Program Files\Sybase\PowerDesigner Trial 11\Resource Files\DBMS\oracl9i2.xdb文件

     修改好后,再cdm转为pdm时,选择“Copy the DBMS definition in model”把把这个资源文件拷贝到模型中。

12、由CDM生成PDM时,自动生成的外键的重命名

PDM Generation Options->Detail->FK index names默认是%REFR%_FK,改为FK_%REFRCODE%,其中%REFRCODE%指的就是CDM中Relationship的code!另外自动生成的父字段的规则是PDM Generation Options->Detail->FK column name template中设置的,默认是%.3:PARENT%_%COLUMN%,可以改为Par%COLUMN%表示是父字段!

13、如何防止一对一的关系生成两个引用(外键)

要定义关系的支配方向,占支配地位的实体(有D标志)变为父表。

在cdm中双击一对一关系->Detail->Dominant role选择支配关系

14、修改报表模板中一些术语的定义

即文件:C:\Program Files\Sybase\PowerDesigner Trial 11\Resource Files\Report Languages\Chinese.xrl

Tools-Resources-Report Languages-选择Chinese-单击Properties或双击目标

修改某些对象的名称:Object Attributes\Physical Data Model\Column\

        ForeignKey:外键

        Mandatory:为空

        Primary:主键

        Table:表

用查找替换,把“表格”替换成“表”

修改显示的内容为别的:Values Mapping\Lists\Standard,添加TRUE的转化列为是,FALSE的转化列为空

另外Report-Title Page里可以设置标题信息

15、

PowerDesigner11中批量根据对象的name生成comment的脚本

'******************************************************************************

'* File:     name2comment.vbs

'* Purpose:  Database generation cannot use object names anymore

'            in version 7 and above.

'            It always uses the object codes.

'

'            In case the object codes are not aligned with your

'            object names in your model, this script will copy

'            the object Name onto the object comment for

'            the Tables and Columns.

'

'* Title:    把对象name拷入comment属性中

'* Version:  1.0

'* Author:

'* 执行方法:PD11 -- Open PDM -- Tools --  Execute Commands -- Run Script

'******************************************************************************

Option Explicit

ValidationMode = True

InteractiveMode = im_Batch

Dim mdl ' the current model

' 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

' This routine copy name into code for each table, each column and each view

' of the current folder

Private sub ProcessFolder(folder)

   Dim Tab'running  table

   for each Tab in folder.tables

      if not tab.isShortcut then

         tab.comment = tab.name

         Dim col ' running column

         for each col in tab.columns

            col.comment= col.name

         next

      end if

   next

   Dim view 'running view

   for each view in folder.Views

      if not view.isShortcut then

         view.comment = view.name

      end if

   next

   ' go into the sub-packages

   Dim f ' running folder

   For Each f In folder.Packages

      if not f.IsShortcut then

         ProcessFolder f

      end if

   Next

end sub

16、PowerDesigner 生成SQL的Existence of refernce错误问题

现象:用PowerDesigner生成SQL语句时,提示Existence of refernce错误。

原因:该表没有与其他表的关联(如外键等),而PowerDesigner需要存在一个refernce才能生成SQL.

解决方法:

    在工具栏空白处右键打开Palette面板,选中Link/Extended Dependency 按钮,然后在提示出错的表上添加到自己的Dependency。

    重新生成SQL,你将发现刚才提示的错误没有了,问题解决。

17、利用PowerDesigner批量生成测试数据

主要解决方法:

A:在PowerDesigner 建表

B:然后给每一个表的字段建立相应的摘要文件

步骤如下:

Model->Test Data Profiles配置每一个字段摘要文件General:输入Name、Code、

选择Class(数字、字符、时间)类型

选择Generation Source: Automatic、List、ODBC、File Detail:配置字段相关信息

所有字段摘要文件配置完成后双击该表->选择字段->Detail->选择Test Data Parameters 摘要文件如果字段值与其它字段有关系在: Computed Expression 中输入计算列--生成测试数据:

DataBase->Generation Test Data->

选择:Genration 类型(Sript、ODBC)

     Selection(选择要生成的表)

     Test Data Genration(Default number of rows 生成记录行数)