PowerDesigner12 简单应用
一直不是对PowerDesigner很熟悉,近期频繁笔试,很多都问这个工具,所以今天下午简单学习了一下。
一、创建概念模型
1.在File下选择New中的Conceptual Data Model:

2.在打开的视图窗口中使用工具箱中的实体工具创建两个实体,分别为学生表和班级表:

实体的属性窗口:

添加属性:

其中:M:即Mandatory ,强制属性,表示该属性必填,不能为空;
P:即Primary Identifer 是否是主标识符,表示实体的唯一标识符,即主键;
D:即Displayed 表示在实体符号中是否显示。
单击Data Type下方的方块按钮可以选择数据类型:

使用上面方法创建班级表,结果图如下:

创建外键关系,学生表和班级表是多对一的关系,使用工具箱的关系创建工具在班级表上单击并拖到学生表上放开,形成如下的图:

二、物理模型
单击菜单栏上的Tools菜单中的Check Model来检查上面的概念模型的正确性。
如果没有错误存在,则选择Tools菜单中的Genterate Physical Data Model,出现如下窗口:

我选用的是mysql5.0数据库,生产结果如下:

我们可以看到在学生表中自动创建了班级表的外键。
再来看一下怎么设置主键的自动增长:
双击学生表或班级表打开表属性窗口,选择Columns选项卡,在主键字段上双击,弹出Columns Properties窗口:

只需选中Identity属性即可(注:这个必须在物理模型下完成,在概念模型下是没有这个选项的,因为不同数据库的自增长的实现方式是不一样的)。
三、生成SQL文件
选择菜单栏中的DataBases菜单中的Grenerate DataBase,弹出如下窗口:

点击确定,可以看到生成的sql:
这样就完成了PowerDesigner的简单应用。
<我的原创,转载请注明出处!!!>
一、创建概念模型
1.在File下选择New中的Conceptual Data Model:

2.在打开的视图窗口中使用工具箱中的实体工具创建两个实体,分别为学生表和班级表:

实体的属性窗口:

添加属性:

其中:M:即Mandatory ,强制属性,表示该属性必填,不能为空;
P:即Primary Identifer 是否是主标识符,表示实体的唯一标识符,即主键;
D:即Displayed 表示在实体符号中是否显示。
单击Data Type下方的方块按钮可以选择数据类型:

使用上面方法创建班级表,结果图如下:

创建外键关系,学生表和班级表是多对一的关系,使用工具箱的关系创建工具在班级表上单击并拖到学生表上放开,形成如下的图:

二、物理模型
单击菜单栏上的Tools菜单中的Check Model来检查上面的概念模型的正确性。
如果没有错误存在,则选择Tools菜单中的Genterate Physical Data Model,出现如下窗口:

我选用的是mysql5.0数据库,生产结果如下:

我们可以看到在学生表中自动创建了班级表的外键。
再来看一下怎么设置主键的自动增长:
双击学生表或班级表打开表属性窗口,选择Columns选项卡,在主键字段上双击,弹出Columns Properties窗口:

只需选中Identity属性即可(注:这个必须在物理模型下完成,在概念模型下是没有这个选项的,因为不同数据库的自增长的实现方式是不一样的)。
三、生成SQL文件
选择菜单栏中的DataBases菜单中的Grenerate DataBase,弹出如下窗口:

点击确定,可以看到生成的sql:
1 /*==============================================================*/
2 /* DBMS name: MySQL 5.0 */
3 /* Created on: 2007-6-7 0:27:29 */
4 /*==============================================================*/
5
6
7 drop table if exists Student;
8
9 drop table if exists classes;
10
11 /*==============================================================*/
12 /* Table: Student */
13 /*==============================================================*/
14 create table Student
15 (
16 sid int not null auto_increment,
17 cid int,
18 sname varchar(50) not null,
19 primary key (sid)
20 );
21
22 /*==============================================================*/
23 /* Table: classes */
24 /*==============================================================*/
25 create table classes
26 (
27 cid int not null,
28 cname varchar(50) not null,
29 primary key (cid)
30 );
31
32 alter table Student add constraint FK_Relationship_1 foreign key (cid)
33 references classes (cid) on delete restrict on update restrict;
34
35
2 /* DBMS name: MySQL 5.0 */
3 /* Created on: 2007-6-7 0:27:29 */
4 /*==============================================================*/
5
6
7 drop table if exists Student;
8
9 drop table if exists classes;
10
11 /*==============================================================*/
12 /* Table: Student */
13 /*==============================================================*/
14 create table Student
15 (
16 sid int not null auto_increment,
17 cid int,
18 sname varchar(50) not null,
19 primary key (sid)
20 );
21
22 /*==============================================================*/
23 /* Table: classes */
24 /*==============================================================*/
25 create table classes
26 (
27 cid int not null,
28 cname varchar(50) not null,
29 primary key (cid)
30 );
31
32 alter table Student add constraint FK_Relationship_1 foreign key (cid)
33 references classes (cid) on delete restrict on update restrict;
34
35
这样就完成了PowerDesigner的简单应用。
<我的原创,转载请注明出处!!!>