使用PowerDesigner导入表+PowerDesigner画ER图+PowerDesigner设置外键
ps:
①ER图:就是PD中的 Physical Diagram
一、导入表,并设置备注为PD中的显示名称
1、新建数据库模型


2、导入表——见参考
- 最好每张表都把生成主键的名字修改了,不然会产生错误的字段
- -- 建表语句1_未修改前的
- CREATE TABLE "TABLE_1"
- (
- "COLUMN_11" CHAR(10),
- "ID" CHAR(32) NOT NULL,
- "AGE" NUMBER(22,6),
- "C_2222" CHAR(10),
- UNIQUE("AGE"),
- NOT CLUSTER PRIMARY KEY("ID")
- ) STORAGE(ON "MAIN", CLUSTERBTR) ;
- COMMENT ON COLUMN "TABLE_1"."AGE" IS 'CS_AA';
- COMMENT ON COLUMN "TABLE_1"."COLUMN_11" IS 'CS_11';
- COMMENT ON COLUMN "TABLE_1"."C_2222" IS 'CS_';
- COMMENT ON COLUMN "TABLE_1"."ID" IS 'CS_DD';
- -- 建表语句2_修改之后的
- -- 主键的名字规则:PK_表名
- CREATE TABLE "TABLE_1"
- (
- "COLUMN_11" CHAR(10),
- "ID" CHAR(32) NOT NULL,
- "AGE" NUMBER(22,6),
- "C_2222" CHAR(10),
- UNIQUE("AGE"),
- constraint PK_CS1 PRIMARY KEY("ID")
- ) STORAGE(ON "MAIN", CLUSTERBTR) ;
- COMMENT ON COLUMN "TABLE_1"."AGE" IS 'CS_AA';
- COMMENT ON COLUMN "TABLE_1"."COLUMN_11" IS 'CS_11';
- COMMENT ON COLUMN "TABLE_1"."C_2222" IS 'CS_';
- COMMENT ON COLUMN "TABLE_1"."ID" IS 'CS_DD';
复制代码 修改详情:

- 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
- Private sub ProcessFolder(folder)
- On Error Resume Next
- Dim Tab 'running table
- for each Tab in folder.tables
- if not tab.isShortcut then
- tab.name = tab.comment
- Dim col ' running column
- for each col in tab.columns
- if col.comment="" then
- else
- col.name= col.comment
- end if
- next
- end if
- next
- Dim view 'running view
- for each view in folder.Views
- if not view.isShortcut then
- view.name = view.comment
- 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
复制代码 二、画图
1、参考——规范:
设计规范——有需要的私我。或者评论
2、新建ER图


3、连接有外键关系的两张表(同一张表出现在不同的ER图中的情况)
①工具栏中的这个图标,可以把拖入ER图的有外键关联的表连接起来。
——这个功能适用于,同一张表出现在不同的ER图中。

呼出界面:

②其他工具栏:

4、绘制外键的线
参考:https://www.somode.com/jiaocheng/36995.html
4.1、打开面板


4.2、外键设置
①、如Table_2(从表) 中的 TABLE_ID 是 TABLE_1(主表) 的 ID 的外键。

②、双击连线,设置如下:

- 设置是否在生成sql的时候生成外键。(不生成表示:只有ER图展示,sql中不会有)



见①。子表的外键字段出现 就是对的
4.3、显示外键线上的名字
参考:https://www.cnblogs.com/EasonJim/p/4715282.html
①结果

②操作


5、格式设置
5.1、把table1的格式弄到table2上。

5.2、给外键的线赋予格式

5.3、获取格式、应用格式
①结果:

②操作步奏:
1)表:


2)线:


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |