49
1 Chapter 11 Entity-Relationship Modeling Transparencies Last Updated: 25 April 2011 By M. Arief http://arief.ismy.web.id

1 Chapter 11 Entity-Relationship Modeling Transparencies Last Updated: 25 April 2011 By M. Arief

Embed Size (px)

Citation preview

1

Chapter 11

Entity-Relationship ModelingTransparencies

Last Updated: 25 April 2011By M. Arief

http://arief.ismy.web.id

2

Database Design

Approaches include:– Bottom-up

» Attributes Relation, Entities

– Top-down» Relation, Entities Attributes

– Inside-out» Attributes Major entities Other entities

– Mixed

http://arief.ismy.web.id

3

Chapter 11 - Objectives

How to use Entity–Relationship (ER) modeling in database design.

Basic concepts associated with ER model.

Diagrammatic technique for displaying ER model using Unified Modeling Language (UML).

http://arief.ismy.web.id

4

ER Diagram of Branch View of DreamHome

http://arief.ismy.web.id

5

Concepts of the ER Model

Entity types

Relationship types

Attributes

http://arief.ismy.web.id

6

Entity Type Entity type

– Group of “objects” with same properties, identified by enterprise as having an independent existence.

Object

- something that is or is capable of being seen, touched, or otherwise sensed, and about which users store data and associate behavior.

Entity occurrence– Uniquely identifiable object of an entity type.

http://arief.ismy.web.id

7

Examples of Entity Types

http://arief.ismy.web.id

8

Example of entity occurrence

Student ID Last Name First Name

2144 Arnold Betty

3122 Taylor John

3843 Simmons Lisa

9844 Macy Bill

2837 Leath Heather

2293 Wrench Tim

Entity occurrence

Entity: student

http://arief.ismy.web.id

9

ER Diagram of Staff and Branch Entity Types

UML: First letter of each word is in upper caseEx. PropertyForRent

http://arief.ismy.web.id

10

Relationship Types

Relationship type– Set of meaningful associations among entity

types.

Relationship occurrence– Uniquely identifiable association, which

includes one occurrence from each participating entity type.

http://arief.ismy.web.id

11

Semantic Net of Has Relationship Type

http://arief.ismy.web.id

12

ER Diagram of Branch Has Staff Relationship

UML: - First letter of each word is in upper case Ex. LeasedBy

- Use arrow symbolhttp://arief.ismy.web.id

13

Relationship Types

Degree of a Relationship– Number of participating entities in relationship.

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

http://arief.ismy.web.id

14

Binary Relationship called POwns

http://arief.ismy.web.id

15

Ternary Relationship called Registers

Other example: Project, Location, Employee, Assignment

http://arief.ismy.web.id

16

Quaternary Relationship called Arranges

http://arief.ismy.web.id

17

Relationship Types

Recursive Relationship– Relationship type where same entity type

participates more than once in different roles unary relationship.

Relationships may be given role names to indicate purpose that each participating entity type plays in a relationship.

http://arief.ismy.web.id

18

Recursive Relationship called Supervises with Role Names

http://arief.ismy.web.id

19

Other example of Recursive Relationship

http://arief.ismy.web.id

20

Entities associated through two distinct Relationships with Role Names

http://arief.ismy.web.id

21

Attributes

Attribute– Property of an entity or a relationship type.

» UML: first letter of first word is in lower case, first letter of other words is in upper case

Attribute Domain– Set of allowable values for one or more

attributes.

http://arief.ismy.web.id

22

Attributes

Simple Attribute– Attribute composed of a single component

with an independent existence.» Ex. position, salary

Composite Attribute– Attribute composed of multiple components,

each with an independent existence.» Ex. address: street+city+postcode

http://arief.ismy.web.id

23

Attributes

Single-valued Attribute– Attribute that holds a single value for each

occurrence of an entity type. » Ex. branchNo

Multi-valued Attribute– Attribute that holds multiple values for each

occurrence of an entity type. » Ex. UML: telNo [1..3]

http://arief.ismy.web.id

24

Attributes

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 type.

» Ex. /leasedDuration= rentStart – rentFinish

UML: /totalSalary, /totalStaff

http://arief.ismy.web.id

25

Keys Candidate Key

– Minimal set of attributes that uniquely identifies each occurrence of an entity type.

Primary Key– Candidate key selected to uniquely identify each

occurrence of an entity type. » UML: branchNo {PK}

Composite Key– A candidate key that consists of two or more

attributes. » Ex. Advert(propertyNo, newspaperName, dateAdvert, cost)

Composite key: propertyNo+newspaperName,+dateAdverthttp://arief.ismy.web.id

26

ER Diagram of Staff and Branch Entities and their Attributes

http://arief.ismy.web.id

27

Entity Type Strong Entity Type (parent)

– Entity type that is not existence-dependent on some other entity type.

OR

– Each participating entity has its own independent primary key.

Weak Entity Type (child)

– Entity type that is existence-dependent on some other entity type.

OR

– The parent entity’ key is also part of the primary key of the child entity.http://arief.ismy.web.id

28

Strong Entity Type called Client and Weak Entity Type called Preference

http://arief.ismy.web.id

29

Strong and Weak Entity

Weak Entity

Strong Entity

http://arief.ismy.web.id

30

Strong and Weak Entity

http://arief.ismy.web.id

31

Relationship called Advertises with Attributes

Indicate that that the relationship conceals unidentified entity typehttp://arief.ismy.web.id

32

Structural Constraints

Main type of constraint on relationships is called multiplicity.

Multiplicity - number (or range) of possible occurrences of an entity type that may relate to a single occurrence of an associated entity type through a particular relationship.

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

http://arief.ismy.web.id

33

Structural Constraints

The 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 (*:*)

http://arief.ismy.web.id

34

Semantic Net of Staff Manages Branch Relationship Type

http://arief.ismy.web.id

35

Multiplicity of Staff Manages Branch (1:1) Relationship Type

http://arief.ismy.web.id

36

Semantic Net of Staff Oversees PropertyForRent Relationship Type

http://arief.ismy.web.id

37

Multiplicity of Staff Oversees PropertyForRent (1:*) Relationship Type

http://arief.ismy.web.id

38

Semantic Net of Newspaper Advertises PropertyForRent Relationship Type

http://arief.ismy.web.id

39

Multiplicity of Newspaper Advertises PropertyForRent (*:*) Relationship

http://arief.ismy.web.id

40

Structural Constraints

Multiplicity for Complex Relationships – Number (or range) of possible occurrences

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

http://arief.ismy.web.id

41

Semantic Net of Ternary Registers Relationship with Values for Staff and Branch Entities Fixed

http://arief.ismy.web.id

42

CR56/B003

CR57/B003

CR62/B003

CR84/B003

CR91/B003

r1

r2

r3

r4

r5

SG37

SG5

SG14

http://arief.ismy.web.id

43

Multiplicity of Ternary Registers Relationship

http://arief.ismy.web.id

44

Summary of Multiplicity Constraints

http://arief.ismy.web.id

45

Structural Constraints Multiplicity is made up of two types of restrictions on

relationships: cardinality and participation.

Cardinality – Describes maximum number of possible relationship

occurrences for an entity participating in a given relationship type.

Participation– Determines whether all or only some entity occurrences

participate in a relationship.

http://arief.ismy.web.id

46

Multiplicity as Cardinality and Participation Constraints

http://arief.ismy.web.id

47

http://arief.ismy.web.id

48

http://arief.ismy.web.id

49

Introduction to the UML

Unified Modeling Language (UML) – a set of modeling conventions that is used to specify or describe a software system in terms of objects.

– The UML does not prescribe a method for developing systems—only a notation that is now widely accepted as a standard for object modeling.

http://arief.ismy.web.id