1 / 20

在本章中,您将学习: Map an ER diagram to a table 将 ER 图映射到表

在本章中,您将学习: Map an ER diagram to a table 将 ER 图映射到表. 目标. Reflects entities and their relationships, based on the data processing needs of an organization 概念模型根据公司的数据处理需求,反映实体及其关系。

Download Presentation

在本章中,您将学习: Map an ER diagram to a table 将 ER 图映射到表

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 在本章中,您将学习: Map an ER diagram to a table 将 ER 图映射到表 目标

  2. Reflects entities and their relationships, based on the data processing needs of an organization 概念模型根据公司的数据处理需求,反映实体及其关系。 The conceptual model design is not concerned with the implementation and operation phases of database. The conceptual model can be mapped to a relational, hierarchical, or network model 概念模型的设计并不考虑数据库的实现及操作阶段,概念模型可以映射到关系、分层或网络模型。 Is independent of individual applications, database management systems, hardware, and physical storage of data. 它独立于应用程序、数据库管理系统、硬件和数据的物理存储。 Data analysis is the first step in designing a conceptual model. 设计概念模型第一步数据分析.(收集数据—整理消除重复数据—识别实体、属性、关系) Draw ER diagram 画ER图。 Conceptual Model 概念模型

  3. A database that conforms to an ER diagram can be represented by a collection of tables in the relational system. 在关系系统中,符合 ER 图的数据库可以由表的集合来表示。 The mapping of ER diagrams to tables can be discussed in relation to the following 让我们来讨论 ER 图到表的映射: Regular entities 常规实体 Attributes 属性 Relationships 关系 Weak entities 弱实体 Subtypes and Supertypes 子类型和超类型 Mapping ERDs to Tables 将 ER 图映射到表

  4. They can exist in isolation, independent of any other entity. 它们可以孤立地存在,与任何其他实体无关。 They are the “building blocks” of the database 它们是数据库的“构建块”。 Each regular entity maps to a table. 每个常规实体映射到表。 Regular Entities 常规实体 STUDENT ISSUES BOOKS

  5. Each property or attribute shown in the ER diagram maps to a column in the appropriate table. ER 图中显示的每个特性或属性映射到相应表中的列。[P2.4] The primary key in the table is identified as the key in the ER diagram. 在ER图中标识的键属性映射到表中做为主键。 Attributes 属性 ROLL_NO STUDENT ISSUES BOOKS PRICE NAME CODE DESC ADDRESS

  6. Each type of relationship maps to tables in a different manner in the relational database management system. 在关系数据库管理系统中,每种关系以不同的方式映射到表。 The most important principle is to create tables where information from the real world is stored and retrieved in an optimal way; that is, a minimum number of tables with a minimum number of attributes. 最重要的一个原则是要创建一些表,通过这些表,使现实世界中的信息能够以最佳的方式存储和获取,即,创建最少数量的表,每个表具有最少的属性数。 In a relational system, a join operation retrieves all information by combining two or more tables. 在关系系统中,连接操作通过将两个或多个表组合起来以获取所有信息。 有以下类型: One-to-One 一对一 One-to-Many 一对多 Many-to-Many 多对多 Relationships 关系

  7. In one-to-one relationships, one instance of an entity can relate to only one instance of the related entity. 在一对一关系中,一个实体的实例只与相关实体的一个实例相关联。 有两种常见的映射方法: One way to handle it is y storing a foreign key in either table 创建两个表,在任意一个表中添加一个外键和关系的属性。 Another way is to merge the two tables into one for faster access. 将两个实体合并为一个表 一对一关系 One –to – One 1 1 STUDENT Does PROJECT

  8. In one-to-many relationship, one instance of an entity can relate to more than one instance of the related entity. 在一对多关系中,一个实体的实例可以与相关实体的多个实例相关联。 映射方法: 映射为两个表,在多的那端的表中添加一个外键列 一对多关系 One –to – Many 1 m DEPARTMENT HAS EMPLOYEE

  9. 映射方法: 将实体映射为表,将关系也映射为一个表,并在关系表中添加两个外键列,分别映射到两个实体表的主键 关系表的主键可以是复合主键也可以新增一个主键 多对多关系 Many –to – Many m m STUDENT ISSUES BOOKS

  10. A weak entity is an entity whose existence depends on some other entity. 弱实体是这样一种实体,它的存在要依赖于其他实体。 It cannot exist if the entity on which it depends does not exist. 如果它所依赖的实体不存在,那么它也不能存在。 将弱实体映射为一张表,并在表中增加一列外键对所依赖的实体的引用。 Weak Entities 弱实体

  11. Each entity type (subtypes and supertypes) maps to a separate table. 每个实体类型(子类型或超类型)映射到不同的表。 The primary key of the supertype is the foreign key of the subtype 超类型的主键是子类型的外键: 它创建两者之间的链接。 子类型的外键也是其主键。 子类型和超类型 CODE CONTENT COURSE NAME STANDALONE SEMESTER DUARATION SEMESTER_NO COURSE(CODE,NAME,CONTENT) STANDALONE(CODE,DUATION) SEMESTER(CODE,SEMESTER_NO)

  12. Attributes 属性: Do not introduce any unnecessary attributes 不要引入任何不需要的属性。 An attribute serves three purposes 属性有三个作用: To identify its owner entity 标识其所有者实体 To refer to another entity 引用另一个实体 To simplify the description of an entity 简化实体描述 如果有具有相同属性的多个实体,则要合并。【P2.13】 Keys 键: Relational systems require keys that uniquely identify the rows of a table. 关系系统需要能够唯一标识表行的键。 有各种类型的键: Primary Key 主键 Foreign Key 外键 Candidate 候选键 Alternate 替换键 Composite 组合键 Tips on Logical Database Design 逻辑数据库设计技巧

  13. Any attribute (or set of attributes) that uniquely identifies a row in a table is a candidate for the primary key,such an attribute is called a candidate key. 能够唯一标识表中行的属性(或属性集)是主键的一个候选键。 这样的属性称为 候选键。 Any attribute that is a candidate for the primary key but is not the primary key is called the alternate key. 任何一个作为主键的候选键、但它又不是主键的属性,这样的属性称为替换键。 Keys can be simple or composite 键可以是简单的或组合的键: A simple key is composed of a single attribute. 简单键由单个属性组成。 A composite key, on the other hand, comprises two or more attributes. 组合键则是由多个属性组合起来。[P2.15] 逻辑数据库设计技巧(续)

  14. 定义以下术语: Candidate Key 候选键 Alternate Key 替换键 课间思考 • 答案: • 能够唯一标识表行的任何属性(或属性集)是主键的一个候选。这样的属性称为候选键。 • 任何是主键的候选但不是主键的属性,这样的属性称为替换键。

  15. Entities 实体: Some attributes may acquire further attributes during database design and become entities. 数据库设计期间某些属性可以获得进一步的属性来限制自己,并且成为实体。 逻辑数据库设计技巧(续) EMPLOYEE STATE CITY ADDRESS EMPNO EMPLOYEE SITUATED ADDRESS BLOCK STREET

  16. Subentities 子实体: Replace optional attributes of an entity with subentities. This is called specialization. 用子实体来替换可选属性。这被称为规范化。 Specialization is the result of taking a subset of a higher-level entity set to form a lower-level entity set. 规范化是采用高级实体集的子集来形成低级实体集的结果。【P2.17】 Generalization is the result of taking the union of two or more lower-level entity sets to produce a higher‑level entity set. 一般化是采用两个或多个低级实体集来产生高级实体集的结果。【P2.18】 逻辑数据库设计技巧(续)

  17. 问题描述 将ER 图映射到相应的表。【P2.19】 演示:将 ER 图映射到表

  18. 在本章中,您学习了: The conceptual model reflects entities and their relationships. Data analysis helps determine entities and relationships. The conceptual model is independent of the system where it is to be implemented. 概念模型反映实体及其实体之间的关系。数据分析帮助您确定实体和关系。概念性模型独立于实施它的系统。 Regular entities are not dependent. They can exist in isolation, independent of any other entity. 常规实体是独立的。它们可以独立存在,不依赖于其他实体。 Each entity maps to a table. Each attribute in an E/R diagram maps to an attribute in a table. 每个实体映射到表。ER 图中的每个属性映射到表中的列。 Entities with common attributes should be merged. Attributes may acquire further attributes and become entities. 具有公共属性的实体应该合并起来,属性可以获得进一步获得属性,并且成为实体。 The mapping of relationships depends on the type of relationship. Each type of relationship maps to tables in a different manner in the relational database management system. 关系映射取决于关系类型。每种关系以不同的方式映射到关系数据库管理系统中的表。 小结

  19. In one-to-one relationships, one instance of an entity can relate to only one instance of the related entity. 在一对一关系中,实体的一个实例可以只与相关实体的一个实例相关联。 In a one-to-many relationship, one instance of an entity can relate to more than one instance of the related entity. 在一对多关系中,实体的一个实例可以与相关实体的多个实例相关联。 Many-to-many relationships map to tables. One-to-one relationships are not very common and may map to foreign keys in tables. 多对多关系映射到表。一对一关系不是十分常用的关系,并且可以映射到表中的外键。 A weak entity is an entity whose existence depends on some other entity. 弱实体是其存在需要依赖于其他实体的实体。 A subtype is a subset of another entity. A subtype is always dependent on supertype for its existence. 子类型是另一个实体的子集。子类型的存在总是依赖于其他的超类型。 The primary key of the supertype is the foreign key of the subtype. It creates a link between the two. 超类型的主键是子类型的外键。它创建两者之间的链接。 小结(续)

  20. A candidate key is a candidate for the primary key. An alternate key is a candidate key that is not a primary key. 候选键是主键的一个候选,替代键是一个不是主键的候选键。 Optional attributes should be replaced with subentities; this is also called specialization. 可选属性应该由子实体代替。它也称为规范化。 To simplify multiple references, a new superentity should be introduced; this is also called generalization. 要简化多个引用,应该引入一个新的超级实体,这也称为一般化。 小结(续)

More Related