版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、面向对象的数据库技术培训(1) -基于PowerDesinger9.5的数据库建模,演讲人:王天池,提 纲,PowerDesigner介绍,数据库逻辑建模,正向工程与逆向工程,数据库物理建模,数据库设计文档,实践体验分享,逻辑模型和物理模型的转换,提 纲,PowerDesigner介绍 PowerDesigner是什么? 谁使用PowerDesigner? PowerDesigner9.5 IDE体验,数据库逻辑建模,正向工程与逆向工程,数据库物理建模,数据库设计文档,实践体验分享,PowerDesigner是什么(1),PowerDesigner is a leading, truly in
2、tegrated enterprise application analysis and design environment with full-featured business, data, and object modeling capabilities。,Business Process Modeling,Object Modeling,Data Modeling,Enterprise Repository,PowerDesigner是什么(2),谁使用PowerDesigner?,PowerDesigner9.5 IDE 体验(1),PowerDesigner9.5 IDE 体验(
3、2),提 纲,PowerDesigner介绍,数据库概念模型 什么是概念模型 概念模型对象介绍 定义概念模型,正向工程与逆向工程,数据库物理模型,数据库设计文档,实践体验分享,逻辑模型和物理模型的转换,什么是概念模型(CDM),A CDM represents the overall logical structure of a database, which is independent of any software or data storage structure. A conceptual model often contains data objects not yet imple
4、mented in the physical database. It gives a formal representation of the data needed to run an enterprise or a business activity.,Conceptual Data Model,如何表达数据库的逻辑结构,ERD(Entity Relationship Diagrams),概念模型对象介绍,Entity,Inheritance,Relationship,Association Link,Domain,Data item,Entity attribute,Associati
5、on,Identifier,定义概念模型(1),Create a new CDM Import one or more existing CDM Generate a CDM from a PDM Generate a CDM from an OOM Generate a CDM from a CDM Import an ERwin model (.ERX),新建概念模型(CDM),打开/分离概念模型(CDM),Opening an existing CDM,Detaching a CDM from the workspace,定义概念模型(2),定义实体(Entity),定义关系(Relat
6、ionship),定义数据项(Data Item),定义数据域(Domain),定义概念模型(3),定义数据域(Domain),扩展的数据类型,标准化不同数据项中同一数据类型,从“Model-Domains”启动数据域定义功能,定义概念模型(4),定义数据项(Data Item),数据项是信息系统中实际存在的或逻辑上的信息元,标准化不同实体中同一数据项,从“Mode-Data Items”启动数据项定义功能,定义概念模型(5),定义实体(Entity),在信息系统中用来存储信息的对象,实体是数据项(DataItem)的集合,实体属性不包括外键(通过关系表达) 尽量通过重用方式来定义实体属性 实
7、体定义体验,定义概念模型(6),定义实体(Entity),在信息系统中用来存储信息的对象,实体是数据项(DataItem)的集合,实体定义体验,定义概念模型(7),定义关系(Relationship),A relationship is a link between entities,定义关系 定义关系类型 定义关系基数(Cardinality) 定义强制关系( Mandatory) 定义依赖关系(Dependent) 定义支配关系(Dominant) 定义继承关系(Inheritance),通过拖拽Relationship图标来创建关系,定义概念模型(8),定义关系类型(Relationsh
8、ip) One to one,One to Many,Many to One and Many to Many。,定义关系基数(Cardinality) 表示实体A对于实体B可能存在实例数,分别0.1,0.n,1.1,1.n四种情况 关系基数是随着关系类型变化而变化的,定义概念模型(9),定义强制关系( Mandatory) 强制属性标示实体间的关系是强制(至少一个实例)的还是可选的 (没有实例);相对应的基数只能为1.1和1.n两种情况。 图示,定义依赖关系(Dependent) 当一个实体A本身的属性不足于区分一条记录而要借助于另外一个实体B(有关系的)的标识属性来组合标识一个记录的关系
9、实体A的主键由实体A的某些属性和实体B标识属性组成 Many to Many关系不存在依赖性 被依赖实体的主键在转换成物理模型时会自动作为一个列添加到依赖表中,定义概念模型(10),定义支配关系(Dominant) 只有One to One关系存在支配关系 To B表示,支配;通俗来说实体A是父实体,而实体B是子实体。,定义概念模型(11),定义继承关系(Inheritance),类似OO中的继承 父级实体包含子实体共同的属性,定义概念模型(12),定义关系体验,定义概念模型(13),定义关系例子,一个账户可以没有或多条交易记录;一条交易记录可以没有账户或只有一个账户。,定义概念模型(14),
10、定义关系例子,一个账户可以没有或多条交易记录;一条交易记录必须有且只有一个账户。,定义概念模型(15),定义关系例子,一个账户可以没有或多条交易记录;一条交易记录必须有且只有一个账户。 并且流水账记录要依赖于帐户信息。,提 纲,PowerDesigner介绍,数据库概念建模,正向工程与逆向工程,数据库物理模型 什么是物理模型 模型对象介绍 定义物理模型,数据库设计文档,实践体验分享,逻辑模型和物理模型的转换,什么是物理数据模型,Physical Data Model(PDM) The PDM is a database design tool for defining the implemen
11、tation of physical structures and data queries. 数据库和数据仓库建模 物理数据库模型源自数据库逻辑模型 与具体数据库系统有关,物理数据模型对象,数据表(Table) 列(Column) 键(Key) 主键(Primary Key) 外键(Foreign Key) 唯一键(Alternate key) 索引(Index) 引用(Reference) 视图(View) 存储过程(Procedure),定义物理模型(1),新建物理模型 Create a new PDM Reverse engineer a database into a PDM Gen
12、erate a PDM from a CDM Generate a PDM from an OOM Import an ERwin model (.erx),设置数据库管理系统,定义物理模型(2),定义列(Column),定义引用(Reference),定义数据表(Table),定义数据域(Domain),定义键(Key),定义索引(Index),定义视图(View),定义存储过程和触发器,定义物理模型(3),定义数据表(Table) A table represents a collection of data arranged in columns and rows. 相当于数据库中数据表
13、 创建方式 From Diagram From Browser From Table List,定义物理模型(4),定义数据域(Domain) 列属性值的集合 相同列在不同表中的标准化 域的属性 Data type, length, and precision Check parameters Business rules Mandatory property,定义物理模型(5),定义列(Column) 相当于数据库中的字段 依附于数据表而存在 选择数据表属性中的“Columns”属性页进行列的定义 支持列从一张表到另外一张表的拷贝,定义物理模型(6),定义键(Key) A key is a
14、column, or a combination of columns, that uniquely identifies a row in a table。 Primary Key Foreign Key 随着引用(Reference)创建而创建 Alternate Key 命名规范 Primary Key: PK_TableCode Foreign Key: FK_ParentTableCode_ChildTableCode_ColumnCode Alternate Key:AK_Tablecode_ColumnCode(s),定义键(Key) A key is a column, or
15、a combination of columns, that uniquely identifies a row in a table。 Primary Key Foreign Key 随着引用(Reference)创建而创建 Alternate Key 命名规范 Primary Key: PK_TableCode Foreign Key:FK_ParentTableCode_ChildTableCode Alternate Key:AK_Tablecode_ColumnCode(s),定义物理模型(7),定义物理模型(8),定义引用(Reference) A reference is a l
16、ink between a parent table and a child table。 Start at the childtable and end at the parenttable。 Joins: A join is a link between a column in a parent table and a column in a child table (column pair) that is defined within a reference. Integrity: Referential integrity is a collection of rules that
17、govern data consistency between primary keys, alternate keys and foreign keys.37 删除Reference时一定要注意,选择“Delete Symbols Only”,定义物理模型(9),定义引用(Reference) A reference is a link between a parent table and a child table。 Start at the childtable and end at the parenttable。 Joins: A join is a link between a c
18、olumn in a parent table and a column in a child table (column pair) that is defined within a reference. Integrity: Referential integrity is a collection of rules that govern data consistency between primary keys, alternate keys and foreign keys.38,定义物理模型(10),定义索引(Index) An index is a data structure
19、associated with a table that is logically ordered by the values of a key。 选择数据表属性“Indexs”属性页进行定义。,定义物理模型(11),定义视图(View) A view is an alternative way of looking at the data in one or more tables. It is made up of a subset of columns from one or more tables。 创建视图 From “Tool-Create View” menu Creating
20、a view for tables and views selected in the diagram Creating an empty view then selecting tables and views Defining a query for a view 设置视图生成顺序 Extended dependency stereotype,定义物理模型(12),定义视图(View) A view is an alternative way of looking at the data in one or more tables. It is made up of a subset of
21、 columns from one or more tables。 创建视图 From “Tool-Create View” menu Creating a view for tables and views selected in the diagram Creating an empty view then selecting tables and views Defining a query for a view 设置视图生成顺序 Extended dependency stereotype,定义视图(View) A view is an alternative way of looki
22、ng at the data in one or more tables. It is made up of a subset of columns from one or more tables。 创建视图 From “Tool-Create View” menu Creating a view for tables and views selected in the diagram Creating an empty view then selecting tables and views Defining a query for a view 设置视图生成顺序 Extended depe
23、ndency stereotype,定义物理模型(13),定义视图(View) A view is an alternative way of looking at the data in one or more tables. It is made up of a subset of columns from one or more tables。 创建视图 From “Tool-Create View” menu Creating a view for tables and views selected in the diagram Creating an empty view then
24、selecting tables and views Defining a query for a view 设置视图生成顺序 Extended dependency stereotype,定义物理模型(14),定义视图(View) A view is an alternative way of looking at the data in one or more tables. It is made up of a subset of columns from one or more tables。 创建视图 From “Tool-Create View” menu Creating a v
25、iew for tables and views selected in the diagram Creating an empty view then selecting tables and views Defining a query for a view 设置视图生成顺序 Extended dependency stereotype,定义物理模型(15),定义物理模型(16),定义存储过程,A stored procedure is a precompiled collection of SQL statements stored under a name and processed
26、as a unit. 创建存储过程,定义物理模型(17),定义触发器,提 纲,PowerDesigner介绍,数据库逻辑建模,正向工程与逆向工程,数据库物理建模,数据库设计文档,实践体验分享,逻辑模型和物理模型的转换 逻辑模型生成物理模型 物理模型生成逻辑模型,概念模型转成物理模型,模型间对象对应关系 对象对用关系 标识(Identifier)和键对应关系 继承关系和数据表对应关系,模型间数据类型对应关系,PDM生成参数定义,模型间对象对应关系(1),对象对用关系,标识(Identifier)和键对应关系 Primary identifiers generate primary and for
27、eign keys in the PDM. Identifiers that are not primary identifiers generate alternate keys. 与实体间的关系类型有关,模型间对象对应关系(2),标识(Identifier)和键对应关系 非依赖一对多关系 实体的标识都生成各自对应表的主键 “一”实体的标识生成“多”对应表的外键(在此表中增加一个列),依赖一对多关系 和依赖关系差不多,只不过多表要建联合主键(联合“多”实体标识)。,模型间对象对应关系(3),标识(Identifier)和键对应关系 多对多关系(非依赖关系) Primary identifie
28、rs of both entities migrate to a join table as primary/foreign keys,模型间对象对应关系(4),标识(Identifier)和键对应关系 非依赖一对一关系 一定要定义Dominant Role属性 在EntityA-EntityB关系中,EntityA的标识为在EntityB对应表中增加一列,并且设置为外键。,模型间数据类型对应关系,设置DBMS数据类型和PowerDesigner的对应关系 从菜单“Tools-Resources - DBMS”选择相应的DBMS,PDM生成参数定义(1),生成方式 Generate new P
29、hysical Data Model Update existing Physical data Model 参数设置 Option Table parameters Reference Index 选择生成对象,PDM生成参数定义(2),生成方式 Generate new Physical Data Model Update existing Physical data Model,PDM生成参数定义(3),参数设置 Option Table parameters Reference FK_Name Index,PDM生成参数定义(4),选择生成对象,可以按包生成,去掉快捷方式对象,物理模型
30、转成概念模型,模型间对象对应关系 对象对用关系 标识(Identifier)和键对应关系 继承关系和数据表对应关系,模型间数据类型对应关系,CMD生成参数定义,类似于逻辑模型生成物理模型,提 纲,PowerDesigner介绍,数据库逻辑建模,正向工程与逆向工程 正向工程过程 逆向工程过程,数据库物理建模,数据库设计文档,实践体验分享,逻辑模型和物理模型的转换,正向工程(1),正向过程 生成相应DBMS的包含所选对象的SQL脚本的过程 生成数据表和视图 生成触发器和存储过程,步骤 生成数据表和视图 生成触发器和存储过程 执行相应的Sql脚本,在DBMS上建立相应的数据库对象,正向工程(2),生成数据表和视图 从菜单DataBase-Generate DataBase启动向导 生成参数定义 选择生成对象,正向工程(3),生成触发
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 烟草复烤潮润控制技师(中级)考试试卷及答案
- 2026年江苏省句容市高二生物下册期末考试模拟卷附参考答案【黄金题型】
- 2026年湖北省麻城市高二生物下册期末考试检测卷附参考答案(B卷)
- 2025年辽宁省盖州市高二生物下册期末考试模拟卷及答案参考
- 2026年河北省深州市高二生物下册期末考试模拟卷含答案【预热题】
- 2025年江苏省启东市高二生物下册期末考试测试卷附参考答案【考试直接用】
- 2025年四川省万源市高二生物下册期末考试模拟卷及参考答案【典型题】
- 2026年山东省临清市高二生物下册期末考试检测卷及参考答案(考试直接用)
- 2025年青海省玉树市高二生物下册期末考试考试卷含答案(巩固)
- 2025年江苏省泰兴市高二生物下册期末考试模拟卷及参考答案(考试直接用)
- 端午节父亲节双节主题班会课件
- 2025-2026学年度江苏省无锡市七年级下学期期末测试模拟卷(含答案)
- 铁路专用线勘察测量方案
- 城市公交车辆日常安全例检项目及流程
- 2026上海农林职业技术学院公开招聘8名笔试参考试题及答案解析
- 2025年辽宁高中学业水平合格性考试化学试卷真题(含答案详解)
- 2026年麻风病防治知识竞赛复习押题宝典题库附答案详解(预热题)
- 2025年生殖医学(副高)高级职称考试题库及答案
- c30砼回弹值对照表
- 新安标(煤安)现场评审模板教程文件
- 数据库原理-及应用课后习题参考答案
评论
0/150
提交评论