chapter 11

47
Chapter 11 Entity-Relationship modeling Transparencies

Upload: clay

Post on 23-Feb-2016

29 views

Category:

Documents


0 download

DESCRIPTION

Chapter 11. Entity-Relationship modeling Transparencies. Chapter 11 - Objectives. The use of high-level conceptual data models to support database design. The basic concepts associated with the Entity-Relationship (ER) model, a high-level conceptual data model. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 11

Chapter 11

Entity-Relationship modelingTransparencies

Page 2: Chapter 11

2

Chapter 11 - Objectives The use of high-level conceptual data

models to support database design.

The basic concepts associated with the Entity-Relationship (ER) model, a high-level conceptual data model.

A diagrammatic technique for displaying an ER model.

Page 3: Chapter 11

3

Chapter 11 - Objectives How to identify problems called

connection traps, which may occur when creating an ER model.

The limitations of the basic ER modeling concepts and the requirements to model more complex applications using enhanced data modeling concepts.

Page 4: Chapter 11

5

Concepts of the Entity-Relationship Model

Entity types

Relationship types

Attributes

Page 5: Chapter 11

7

Entity Type Entity Type

– An object or concept that is identified by the enterprise as having an independent existence.

Entity– An object or concept that is

uniquely identifiable.

Page 6: Chapter 11

8

Examples of Entity Types

Page 7: Chapter 11

9

Entity Type

Weak Entity Type (dependent entity)– An entity type that is existence-dependent on

some other entity type (parent vs child entity).

Strong Entity Type (independent entity) – An entity type that is not existence-dependent on

some other entity type.

Page 8: Chapter 11

10

Diagrammatic Representation of Strong and Weak Entity Types

Page 9: Chapter 11

11

Attributes Attribute

– A property of an entity or a relationship type.

Attribute Domain– A set of values that may be

assigned to a single-valued attribute.

Page 10: Chapter 11

12

Attributes

Simple Attribute (Salary)– An attribute composed of a single

component with an independent existence.

Composite Attribute (Address)– An attribute composed of multiple

components each with an independent existence.

Page 11: Chapter 11

13

Attributes Single-valued Attribute (Branch

Number)– An attribute that holds a single-

value for a single entity.

Multi-valued Attribute (Tel_No)– An attribute that holds multiple

values for a single entity.

Page 12: Chapter 11

14

Attributes Derived Attribute

– An attribute that represents a value that is derivable from the value of a related attribute or set of attributes, not necessarily in the same entity.

Page 13: Chapter 11

15

Diagrammatic Representation of Entities and their Attributes

Page 14: Chapter 11

16

Keys Candidate Key

– An attribute or set of attributes that uniquely identifies individual occurrences of an entity type.

Primary Key– An entity type may have one or more

possible candidate keys, one of which is selected to be the primary key.

Page 15: Chapter 11

17

Keys Composite Key

– A candidate key that consists of two or more attributes. (Advert entity – Property_no +

Newspaper_name + Date_advert)

Page 16: Chapter 11

Primary vs Foreign Keys Rule: Primary keys are Indicated by the letters PK under the

appropriate column heading(s)  Rule: Primary keys must never be null (PK implies NN)  Rule: Primary key column may not contain duplicate values (PK

implies ND) 

Foreign Key   Rule: Foreign keys are Indicated by the letters FK under the

appropriate column heading(s)

Page 17: Chapter 11

Primary Key Selection

    Select Primary keys that are not likely to change.     Select Primary keys that are short.     Select Primary keys that are numeric.

     Select Primary keys that are familiar to the system user. 

Page 18: Chapter 11

18

Relationship Types Relationship Type

– A meaningful association among entity types.

Relationship (1:1; 1: M; M:M)– An association of entities where

the association includes one entity from each participating entity type.

Page 19: Chapter 11

19

Relationship Types Degree of a Relationship

– The number of participating entities in a relationship.

Recursive Relationship– A relationship where the same

entity participates more than once in a different roles.

Page 20: Chapter 11

21

Diagrammatic Representation of Entities, Relationships, and Primary Key Attributes

Page 21: Chapter 11

22

Binary Relationship called Owns

Page 22: Chapter 11

23

Ternary Relationship called SetsUp

Page 23: Chapter 11

24

Quaternary Relationship called Arranges

Page 24: Chapter 11

25

Recursive Relationship called Supervises

Page 25: Chapter 11

26

Entities associated through two distinct Relationships

Page 26: Chapter 11

27

Relationship called Views with attributes

Page 27: Chapter 11

28

Structural Constraints Two main types of restrictions on

relationships are cardinality and participation constraints.

Cardinality Constraints (Ratio) (non-identifying) – Determines the number of possible

relationships for each participating entity.– Most common degree for relationships is binary with

cardinality ratios of one-to-one (1:1), one-to-many (1:M) or many-to-many (M:N).

Page 28: Chapter 11

29

Structural Constraints Participation Constraints

(Identifying relationship)– Determines whether the

existence of an entity depends on its being related to another entity through the relationship.

Page 29: Chapter 11

Identifying Relationship vs.Non-Identifying Relationship

Identifying Relationship An identifying relationship is a relationship between

two entities in which primary key of one entity appears as a foreign key in the other entity as a key data element or set of data elements. For example, the relationship between parent entity and child entity is an identifying relationship.

Page 30: Chapter 11

Identifying Relationship vs.Non-Identifying Relationship

Non-Identifying Relationship

A non-identifying relationship is a relationship between two entities in which the primary key of one entity appears as a foreign key in the other entity as a non-key data element. For example, the relationship between an Organization entity and a Project entity is a non-identifying relationship. Additionally, the Organization identifier appears as a foreign key (as an element), but not part of the primary key in the Project entity.

Page 31: Chapter 11

Types of Entities Independent Entity (Fundamental entity)

An independent entity is a group of data that exists without dependence upon any other entity. Therefore it does not have any identifying parent(s). Its primary key does not contain a foreign key from any other entity

  Dependent Entity (Attribute Entity)

A dependent entity (or child entity) is a group of data that cannot exist without the support of another entity (or parent entity). Its primary key contains a foreign key from another entity.

Page 32: Chapter 11

Types of Entities

 Associative Entity

An associative entity is an entity that exists when decomposing a many-to-many relationship between two entities. For example, a many-to-many relationship between an entity called Project and another called Organization would result in an

associative entity called Project-Organization.

Page 33: Chapter 11

Participation Constraints Total (Mandatory) –connected by a

double line. Partial (Optional) – connected by a

single line.

Page 34: Chapter 11

31

Staff Manages Branch (1:1) Relationship

Page 35: Chapter 11

33

Staff Oversees Property_for_Rent (1:M) Relationship

Page 36: Chapter 11

35

Newspaper Advertises Property_for_Rent (M:N) Relationship

Page 37: Chapter 11

Types of Associations

0,1

1,M

1,1 0,M

1,1 0.1

1.M 1,M

1:1 1:1

Page 38: Chapter 11

36

Participation Constraints of Branch IsAllocated Staff Relationship

Page 39: Chapter 11

37

Displaying Participation Constraints using (Min, Max) Notation

Relationship: 5:N Branch ------------------- Staff ------------------ 0:1

Page 40: Chapter 11

RelationshipBranch

Staff

Branch #(PK)

Branch Tel #

2

3

123-4567

234-5678

Staff #(PK)

Staff Name Branch # (FK)

101 John 2

102 Dean

Page 41: Chapter 11

A Hierarchy of Models

Subject Level

Entity

DenormalizedEntity

Normalized

Page 42: Chapter 11

38

Problems with ER Models Problems may arise when designing a

conceptual data model called connection traps.

Often due to a misinterpretation of the meaning of certain relationships.

Two main types of connection traps are called fan traps and chasm traps.

Page 43: Chapter 11

39

Problems with ER Models Fan Trap

– When a model represents a relationship between entity types, but the pathway between certain entity occurrences is ambiguous.

Chasm Trap– When a model suggests the existence of a

relationship between entity types, but the pathway does not exist between certain entity occurrences.

Page 44: Chapter 11

40

An Example of a Fan Trap

Page 45: Chapter 11

42

Restructuring ER model to remove Fan Trap

Page 46: Chapter 11

44

An Example of a Chasm Trap

Page 47: Chapter 11

46

ER Model restructured to remove Chasm Trap