Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER...

36
Entity-relationship Modeling Transparencies 1

Transcript of Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER...

Page 1: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

Entity-relationship ModelingTransparencies

1

Page 2: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

ObjectivesHow to use ER modeling in database design. The basic concepts of an ER model called

entities, relationships, and attributes. A diagrammatic technique for displaying an

ER model. How to identify and solve problems in an ER

model called connection traps.

2

Page 3: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

ER modelingTop-down approach to database design. Start by identifying the important data

(called entities) and relationships between the data.

Then add more details such as the information we want to hold about the entities and relationships (called attributes) and any constraints on the entities, relationships, and attributes.

3

Page 4: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

EntitiesEntity

A set of objects with the same properties, which are identified by a user or organization as having an independent existence.

Entity occurrenceEach uniquely identifiable object within a set.

4

Page 5: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Entities with physical and conceptual existence

5

Page 6: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

ER diagram of entities

6

Page 7: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

RelationshipsRelationship

A set of meaningful associations among entities.

Relationship occurrenceEach uniquely identifiable association

within a set. Degree of a relationship

Number of participating entities in relationship.

7

Page 8: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

ER diagram of relationships

8

Page 9: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Relationships

9

Relationship of degree :two is binary; three is ternary;four is quaternary.

Recursive relationshipsRelationship where same entity participates

more than once in different roles. Relationships may be given role names to

indicate purpose that each participating entity plays in a relationship.

Page 10: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Example of ternary relationship

10

Page 11: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Example of a recursive relationship

11

Page 12: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

AttributesAttributes

Property of an entity or a relationship.Hold values that describe each occurrence

of an entity or relationship, and represent the main source of data stored in the database.

Attribute can be classified as being:simple or composite;single-valued or multi-valued;or derived.

12

Page 13: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

AttributesSimple attribute

Attribute composed of a single component. Composite attribute

Attribute composed of multiple components.

13

Page 14: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

AttributesSingle-valued attribute

Attribute that holds a single value for an entity occurrence.

 Multi-valued attributeAttribute that holds multiple values for an

entity occurrence. Derived attribute

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

14

Page 15: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

KeysSuperkey

An attribute, or set of attributes, that uniquely identifies each entity occurrence.

 Candidate keyA superkey that contains only the minimum

number of attributes necessary for unique identification of each entity occurrence.

15

Page 16: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

KeysPrimary key

The candidate key that is selected to identify each entity occurrence.

 Alternate keyThe candidate keys that are not selected as

the primary key of the entity.

16

Page 17: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Diagrammatic representation of entities and attributes

17

Page 18: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

More on EntitiesStrong entity

Entity that is not dependent on the existence of another entity for its primary key.

 Weak entityEntity that is partially or wholly dependent

on the existence of another entity, or entities, for its primary key.

18

Page 19: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Multiplicity constraints Multiplicity constraints on relationships

Represents the number of occurrences of one entity that may relate to a single occurrence of an associated entity.

Represents policies (called business rules) established by user or company.

19

Page 20: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Multiplicity constraintsThe most common degree for

relationships is binary. Binary relationships are generally

referred to as being:one-to-one (1:1)one-to-many (1:*)many-to-many (*:*)

20

Page 21: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

1:1 relationship (a) semantic net and (b) ER model

21

Page 22: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

1:* relationship (a) semantic net and (b) ER model

22

Page 23: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

*:* relationship (a) semantic net and (b) ER model

23

Page 24: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Complex relationshipsMultiplicity is the number (or range) of

possible occurrences of an entity type in an n-ary relationship when other (n-1) values are fixed.

24

Page 25: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Complex relationship (a) semantic net and (b) ER model

25

Page 26: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Summary of multiplicity constraints

26

Page 27: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Multiplicity Made up of two types of restrictions on

relationships: cardinality, and participation.

 Cardinality Describes the number of possible relationships

for each participating entity.  Participation

Determines whether all or only some entity occurrences participate in a relationship.

27

Page 28: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Multiplicity as cardinality and participation constraints

28

Page 29: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Relationship with attributes

29

Page 30: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Problems with ER modelsProblems may arise when designing an ER

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.

30

Page 31: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Problems with ER modelsFan trap

Occurs between related entities that are not directly connected and the indirect pathway that connects them includes two 1:* relationships that fan out from a central entity.

This means that certain entity occurrences that are related can only be connected using a pathway that can be ambiguous.

31

Page 32: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Example of a fan trap (a) ER diagram (b) semantic netCannot tell which member of staff uses car

SH34.

32

Page 33: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Fan trap resolved (c) ER diagram (d) semantic netCan now tell which car staff use.

33

Page 34: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Problems with ER modelsChasm trap

Occurs between related entities that are not directly connected and the indirect pathway that connects them includes partial participation.

This means that certain entity occurrences that are related have no means of connection.

34

Page 35: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Example of a chasm trap (a) ER diagram (b) semantic net Cannot tell which distribution center has

staff S0003 works at.

35

Page 36: Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.

©Pearson Education 2009

Chasm trap resolved (c) ER diagram (d) semantic net Can now tell where staff work

36