local copy on course web site; FASTER

4 downloads 141 Views 863KB Size Report
by David M. Kroenke. Three Schema Model ... Conceptual schema. – A logical view of the database containing a description of ... Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke .
Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques

Fundamentals, Design, and Implementation, 9/e

Three Schema Model ƒ ANSI/SPARC introduced the three schema model in 1975 ƒ It provides a framework describing the role and purpose of data modeling

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/2

Three Schema Model (cont.) ƒ External schema or user view – Representation of how users view the database

ƒ Conceptual schema – A logical view of the database containing a description of all the data and relationships – Independent of any particular means of storing the data – One conceptual schema usually contains many different external schemas

ƒ Internal schema – A representation of a conceptual schema as physically stored on a particular product – A conceptual schema can be represented by many different internal schemas Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/3

E-R Model ƒ Entity-Relationship model is a set of concepts and graphical symbols that can be used to create conceptual schemas ƒ Four versions – – – –

Original E-R model by Peter Chen (1976) Extended E-R model: the most widely used model Information Engineering (IE) by James Martin (1990) IDEF1X national standard by the National Institute of Standards and Technology – Unified Modeling Language (UML) supporting object-oriented methodology

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/4

The Extended E-R Model

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/5

Example: E-R Diagram

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/6

Entities ƒ Something that can be identified and the users want to track – Entity class is a collection of entities described by the entity format in that class – Entity instance is the representation of a particular entity

ƒ There are usually many instances of an entity in an entity class Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/7

Example: Entity

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/8

Attributes ƒ Description of the entity’s characteristics ƒ All instances of a given entity class have the same attributes – Composite attribute: attribute consisting of the group of attributes – Multi-value attributes: attribute with more than one possible value Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/9

Identifiers ƒ Identifiers are attributes that name, or identify, entity instances ƒ The identifier of an entity instance consists of one or more of the entity’s attributes ƒ An identifier may be either unique or non-unique – Unique identifier: the value identifies one and only one entity instance – Non-unique identifier: the value identifies a set of instances

ƒ Composite identifiers: Identifiers that consist of two or more attributes Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/10

Relationships ƒ Entities can be associated with one another in relationships – Relationship classes: associations among entity classes – Relationship instances: associations among entity instances

ƒ Relationships can have attributes ƒ A relationship class can involve many entity classes ƒ Degree of the relationship is the number of entity classes in the relationship

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/11

Example: Degree of the relationship

ƒ Relationships of degree 2 are very common and are often referred to by the term binary relationships Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/12

Binary Relationships ƒ 1:1 ƒ 1:N ƒ N:M

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/13

Recursive Relationship ƒ Recursive relationships are relationships among entities of a single class

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/14

Cardinality ƒ Maximum cardinality indicates the maximum number of entities that can be involved in a relationship ƒ Minimum cardinality indicate that there may or may not be an entity in a relationship

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/15

Weak Entities ƒ Weak entities are those that must logically depend on another entity ƒ Weak entities cannot exist in the database unless another type of entity (strong entity) also exists in the database – ID-dependent entity: the identifier of one entity includes the identifier of another entity Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/16

Example: Weak Entities

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/17

Example: Weak Entities

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/18

Subtype Entities ƒ Subtype entity is an entity that represents a special case of another entity, called supertype ƒ Sometimes called an IS-A relationship ƒ Entities with an IS-A relationship should have the same identifier

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/19

Example: Subtype Entities

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/20

Example: Subtype Entities

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/21

Example: Subtype Entities

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/22

IDEF1X Standard ƒ IDEF1X (Integrated Definition 1, Extended) was announced as a national standard in 1993 ƒ It defines entities, relationships, and attributes in more specific meanings ƒ It changed some of the E-R graphical symbols ƒ It includes definition of domains, a component not present in the extended E-R model ƒ Four Relationship Types – – – –

Non-Identifying Connection Relationships Identifying Connection Relationships Non-Specific Relationships Categorization Relationships

ƒ Products supporting IDEF1X: ERWin, Visio, Design/2000 Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/23

Example: IDEF1X

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/24

Example: IDEF1X

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/25

Example: IDEF1X

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/26

Non-Identifying Connection Relationships ƒ Represent relationship with a dashed line from a parent to a child entity ƒ Default cardinality is 1:N with a mandatory parent and an optional child – 1 indicates exactly one child is required – Z indicates zero or one children

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/27

Non-Identifying Connection Relationships

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/28

Identifying Connection Relationships ƒ Same as ID-dependent relationships in the extended E-R model ƒ Parent’s identifier is always part of the child’s identifier ƒ Relationship are indicated with solid lines, child entities are shown with rounded corners (ID-dependent entities only)

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/29

Identifying Connection Relationships

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/30

Non-Specific Relationships ƒ Simply a many-to-many relationship ƒ Relationships are shown with a filled-in circle on each end of the solid relationship line ƒ Cannot set minimum cardinalities of a non-specific relationship

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/31

Non-Specific Relationships

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/32

Categorization Relationships ƒ A relationship between a generic entity and another entity called a category entity ƒ Called specialization of generalization/subtype relationships (IS-A relationships) in the extended E-R model ƒ Within category clusters, category entities are mutually exclusive ƒ Two types of category clusters: – Complete: every possible type of category for the cluster is shown (denoted by two horizontal lines with a gap in-between) – Incomplete: at least one category is missing (denoted by placing the category cluster circle on top of a single line, no gap between horizontal lines)

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/33

Example: Categorization Relationships

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/34

Example: IDEF1X Model With Relationship Names

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/35

Example: IDEF1X Model With Relationship Names

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/36

Domains ƒ A domain is a named set of values that an attribute can have ƒ It can be a specific list of values or a pre-defined data characteristic, e.g. character string of length less than 75 ƒ Domains reduce ambiguity in data modeling and are practically useful ƒ Two types of domains – Base domain: have a data type and possibly a value list or range definition – Type domain: a subset of a base domain or a subset of another type domain Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/37

Example: Domain Hierarchy

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/38

UML-style E-R Diagrams ƒ The Unified Modeling Language (UML) is a set of structures and techniques for modeling and designing object-oriented programs (OOP) and applications ƒ The concept of UML entities, relationships, and attributes are very similar to those of the extended E-R model ƒ Several OOP constructs are added: – – – –

indicates that the entity class exist in the database UML allows entity class attributes UML supports visibility of attributes and methods UML entities specify constraints and methods in the third segment of the entity classes

ƒ Currently, the object-oriented notation is of limited practical value Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/39

Example: UML

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/40

Example: UML

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/41

Example: UML

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/42

UML: Weak Entities

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/43

UML: Subtypes

Copyright © 2004 Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke

Chapter 2/44

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques

Fundamentals, Design, and Implementation, 9/e