5 Copyright © 2006, Oracle. All rights reserved. Understanding Entity Relationship Diagrams ( 實體關係圖 ) Part I.

Slides:



Advertisements
Similar presentations
Entity Relationship (ER) Modeling
Advertisements

Entity Relationship (ER) Modeling
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Entity Relationship (ER) Modeling
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Systems Development Life Cycle
Data Modeling is an Analysis Activity
Chapter 5 Understanding Entity Relationship Diagrams.
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
Entity-Relation Modeling Hun Myoung Park, Ph.D., Public Management and Policy Analysis Program Graduate School of International Relations International.
Chapter 3: Modeling Data in the Organization
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 5 Understanding Entity Relationship Diagrams.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Developing Data Models for Business Databases.
Chapter 3: Modeling Data in the Organization
Chapter 4 Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter Five Data Modeling with the Entity-Relationship Model.
Chapter 6 Developing Data Models for Business Databases.
Mapping - 1 Mapping From ER Model to Relational DB.
Chapter 3 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Importance of data modeling Importance of data modeling Write good.
Entity Relationship Modeling Objectives: To illustrate how relationships between entities are defined and refined. To know how relationships are incorporated.
Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Entity Relationship Diagrams (ERDs)
1 © Prentice Hall, 2002 CMIS564: E/R Modeling Dr. Bordoloi Based on Chapter 3; Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
3.1 CSIS 3310 Chapter 3 The Entity-Relationship Model Conceptual Data Modeling.
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Chapter 7 Data Modeling with Entity Relationship Diagrams Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Entity-Relationship (ER) Data Model 概念資料模式 (Based on Chapter 3 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 4)
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
BIS 360 – Lecture Six (Part 2) Conceptual Data Modeling (Chapter 10 and partial Chapter 12)
Chapter 2: Modeling Data in the Organization
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Copyright (c) 2014 Pearson Education, Inc. Introduction to Databases.
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
5 Copyright © 2006, Oracle. All rights reserved. Understanding Entity Relationship Diagrams ( 實體關係圖 ) Part II.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 2: Modeling Data in the Organization.
Database Design, Application Development, and Administration, 5 th Edition Copyright © 2011 by Michael V. Mannino All rights reserved. Chapter 6 Developing.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Chapter 4 Entity Relationship (ER) Modeling.  ER model forms the basis of an ER diagram  ERD represents conceptual database as viewed by end user 
Lecture 4 Conceptual Data Modeling. Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship,
Database Design – Lecture 5 Conceptual Data Modeling – adding attributes.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
1 A Demo of Logical Database Design. 2 Aim of the demo To develop an understanding of the logical view of data and the importance of the relational model.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 4 Entity Relationship (ER) Modeling.
CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education 1 Modern Database Management 11 th Edition, International Edition Jeffrey A. Hoffer,
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 4 ENTITY RELATIONSHIP (ER) MODELING Instructor Ms. Arwa Binsaleh 1.
advanced data modeling
Data Modeling Using the Entity-Relationship (ER) Data Model.
The Entity-Relationship Model, P. I R. Nakatsu. Data Modeling A data model is the relatively simple representation, usually graphic, of the structure.
Chapter 3: Modeling Data in the Organization. Business Rules Statements that define or constrain some aspect of the business Assert business structure.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 3: Modeling Data in the Organization Modern Database Management 9 th Edition Jeffrey.
Ch 05. Basic Symbols ( manino ). Cardinalities Cardinality Notation.
Chapter 5 Understanding Entity Relationship Diagrams.
CHAPTER 2: MODELING DATA IN THE ORGANIZATION (THE BASIC ER-MODEL) © 2013 Pearson Education 1 Modern Database Management 11 th Edition, International Edition.
Department of Mathematics Computer and Information Science1 CS 351: Database Management Systems Christopher I. G. Lanclos Chapter 4.
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
Database Design, Application Development, and Administration, 6 th Edition Copyright © 2015 by Michael V. Mannino. All rights reserved. Chapter 5 Understanding.
IS 4420 Database Fundamentals Chapter 3: Modeling Data in the Organization Leon Chen.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
Chapter 5 Entity-Relationship Modeling
Chapter 2: Modeling Data in the Organization (THE BASIC ER-MODEL)
Tables and Their Characteristics
Database Design – Lecture 4
Database Systems: Design, Implementation, and Management Tenth Edition
Review of Week 1 Database DBMS File systems vs. database systems
Entity Relationship (ER) Modeling
Presentation transcript:

5 Copyright © 2006, Oracle. All rights reserved. Understanding Entity Relationship Diagrams ( 實體關係圖 ) Part I

Outline Notation ( 表示法 ) of Entity Relationship Diagram More Aspects of Relationships Generalization hierarchies ( 歸納類別的階層架構 ) Business rule ( 企業規則 ) representation Diagram rules ( 圖形規則 ) Alternative notations

Importance of Database Relationship Diagram

Basic Elements and Symbols of Entity-Relationship Diagram (ERD) ERDs have three basic elements: Entity type ( 實體類別 ) relationship ( 關係 ) attribute ( 屬性 )

Entity Type ( 實體類別 ) A collection of entities (persons, places, events, or things) of interest An entity is a member or instance ( 實例 ) of an entity type. Entities are uniquely identified to allow tracking across business processes. Represented by a rectangle

Relationship ( 關係 ) A named association among entity types. A relationship represents a two-way or bidirectional association among entities. Most relationships involve two distinct entity types. Course Has Offerings (a verb usually)

Attribute ( 屬性 ) A property of an entity type or relationship. Each attribute has a data type which defines the kind of values and permissible operations on the attribute. Underline(s) indicates that the attribute(s) serves as the primary key of the entity type.

Interpretation of ER Diagram ( ERD, 實體關係圖) ERD has a natural language correspondence. entity types : nouns, relationship : verb/prepositional phrase Interpretation of a relationship can be bidirectional. It can be used to navigate in both directions – From Course to Offering : Has, Provides – From Offering to Course : IsProvidedFor Which word to use for naming a relationship? Try to use active verb; not always possible

Relationship Cardinality Cardinality ( 基數 ) A constraint on the number of entities that participate in a relationship. In an ERD, the minimum and maximum cardinalities are specified for both directions of a relationship.

Instance Diagram ( 實例圖 ) Useful to understand relationship cardinality Lines show connections among entities –Course1 is related to Offering1, Offering2, and Offering3 –Course2 is related to Offering4 –Course3 is not related to any offerings An example of instance diagram

Example of Relationship Cardinality in Instance Diagram An example : Each course is related to a minimum of 0 and maximum of many offerings –Course1 is related to 3 offerings –Course2 is related to 1 offering –Course3 is related to 0 offering Each offering is related to exactly one course

Cardinality Representation in ER Diagram (Crow’s Foot ( 烏鴉腳 ) Notation) - Course is related to a min of 0 and max of many offerings - Offering is related to a min of 1 and max of 1 courses (exactly one)

Classification of Relationship by Relationship Cardinalities Minimum cardinality based Mandatory ( 強制 ) relationship: Minimum cardinality  1 Optional ( 非必要 ) relationship: Minimum cardinality = 0 Maximum cardinality based Functional ( 函數性的 ) or Single-valued( 單值的 ) relationship: Maximum cardinality = 1 1-M relationship: Maximum cardinality = 1 in one direction and maximum cardinality > 1 in the other direction. M-N relationship: Maximum cardinality is > 1 in both directions. 1-1 relationship: Maximum cardinality = 1 in both directions.

Summary of Relationship Classification by Relationship Cardinalities Relationship Classification Cardinality Restrictions Mandatory Minimum cardinality  1 (at one end) OptionalMinimum cardinality = 0 (at one end) Functional or single-valued Maximum cardinality = 1 (at one end) 1-M (1 對多 ) Maximum cardinality = 1 in one direction and maximum cardinality > 1 in the other direction. M-N ( 多對多 ) Maximum cardinality is > 1 in both directions. 1-1 (1 對 1) Maximum cardinality = 1 in both directions.

Existence Dependency ( 存在的依賴 ) An entity that cannot exist unless another related entity exists. A mandatory relationship ( 強制式的關係 ) creates an existence dependency Example: The Offering entity type depends on the Has relationship

Example of Relationship Classification Has relationship is optional to the Course entity type. A Course entity can be stored without being related to an Offering entity. Has relationship is mandatory to the Offering entity type. An Offering entity cannot be stored without a related Course entity.

More Examples on Relationship Classification 1-1 and M-N Relationship Examples 1-1: Maximum cardinality = 1 in both directions. M-N: Maximum cardinality is > 1 in both directions.

ER Diagram vs. Access Relational Diagram ER Diagram Access Relational Diagram Doesn’t show minimum cardinality

Differences Between ERD & Relational Database Diagram 1.No relationship name in relational database diagram ( Instead FKs represent relationships). ERD notation does not use FKs 2.Relational database diagram shows only maximum cardinalities 3.Relational database diagram allow a relationship between two tables only. Some ERD notations allow M-way relationship ( 多方的關係 ). 4.Relationship with attributes is not permitted in the relational database diagram

More Aspects of Relationships on ERD Notation Identification dependency ( 識別的依賴 ) Weak Entities ( 弱實體類別 ) Identifying Relationships ( 識別關係 ) More Relationship Patterns ( 關係樣式 ) M-N Relationships with Attributes (An M-N Relationship is implemented as a table in a D/B) Self-Referencing (Unary) Relationships M-way relationships ( 多方的關係 ) Equivalence between M-N and 1-M relationships   

Identification Dependency ( 識別的依賴 ) Identification dependency is a specialized kind of existence dependency (with minimum cardinality of 1). Weak Entity ( 弱實體類別 ) –An entity type that borrows part or entire of its PK from other entity types –Its unique identification depends on an identifying relationship Identifying relationship ( 識別關係 ) –An identifying relationship creates an identification dependency –Indicates the source of borrowed PK of a weak entity

Identification Dependency Identification dependency involves a weak entity and one or more identifying relationship. Example: Identification Dependency Symbols: Solid relationship line for identifying relationships Diagonal lines in the corners denote weak entities. The PK of Room is a a composite PK. It is combined from RoomNo (local part of its PK) BldgID (borrowed part of its PK) Local Key or Partial PK

Identification Dependency A specialized kind of existence dependency (a mandatory relationship with minimum cardinality of 1 ) The unique identification of Weak entity depends on an identifying relationship The minimum and maximum cardinalities of a weak entity are always 1.

More Relationship Patterns( 樣式 ) M-N Relationships with Attributes Self-Referencing (Unary) Relationships Associative entity types ( 組合的實體類別 ) representing M-way relationships ( 多方關係 )

M-N Relationships with Attributes Relationships can have attributes just like entity types Very typical for M-N relationships Attribute depends on both entity types, not just one of the entity types EnrGrade is an attribute of the M-N relationship Enrollsln

M-N Relationships with Attributes Grade recorded for a student in a particular course offering Depends on the combination of Student and Offering EnrGrade is not part of the Student or Offering entity types

Self-Referencing Relationships ( 自我參照關係 ) Involves connections among members of the same entity type Example: –Employees: supervisory ( 管理的 ) relationships –Courses: prerequisite ( 先修課 ) structures

Self-Referencing Relationships Instance Diagrams (實例圖 ) ERD 1 個直接上司 2 個直接下屬 1 個直接上司 0 個直接下屬 0 個 直接 上司 2 個直接下屬 直接下屬最少 0 個 直接下屬最多 2 個 直接 上司最少 0 個 直接 上司最多 1 個

ERD Notation for Self-Referencing Relationships Instance Diagrams (實例圖 ) ERD 1 門先修 擋修 1 門 1 門先修 擋修 2 門 0 門先修 擋修 1 門 2 門先修 擋修 0 門 先修最少 0 門,最多 2 門 擋修最少 0 門,最多 2 門

Associative Entity Types ( 組合的實體類別 ) for M-way Relationships M-way Relationships ( 多方的關係 ) –Relationships involve more than 2 entity types Notation Example: The Chen Notation A 3-way relationship ( 三方的關係 ) tracks which supplier supplies a part on a specified project The Chen Notation

Associative Entity Types for M-way Relationships Crow's Foot notation does not directly (but indirectly) support M-way relationships –Use an associative entity type and a collection of identifying 1-M relationships to represent an M-way relationship Associative entity type –A weak entity that depends on two or more entity types for its PK — Usually borrows entire PKs from related entity types –A replacement for M-N or M-way relationship

Associative Entity Types for 3-way Relationships Associative entity type The Crow’s Foot Notation that represents a ternary relationship

Equivalence Between M-N & 1-M Relationships An M-N relationship can be replaced by –An associative entity type and –Two identifying 1-M relationships (1 對多的辨識關係 ) Enrollment entity type –Weak entity –PK: Combination of StdSSN and OfferNo

Flexible Associative Entity Type M-N relationship versus associative entity type M-N relationship is preferred (more concise) in most cases. But, associative entity type is more flexible in some situations, e.g. when an M-N relationship must have a relationship with other entity type. An example : Attendance entity type relates to Enrollment –Weak entity (related to Enrollment ‘relationship’) –PK: Combination of AttDate and PK of Enrollment

自我練習 HW 第五章 160 頁 Questions : 5, 7, 8, 11, 15, 16, 17, 18, 19