• No results found

CHAPTER 4: ENTITY RELATIONSHIP MODEL (ER MODEL)

N/A
N/A
Protected

Academic year: 2022

Share "CHAPTER 4: ENTITY RELATIONSHIP MODEL (ER MODEL)"

Copied!
37
0
0

Loading.... (view fulltext now)

Full text

(1)

CHAPTER 4:

ENTITY RELATIONSHIP MODEL

(ER MODEL)

(2)

The Entity Relationship Model (ERM)

• ER model forms the basis of an ER diagram

• ERD represents conceptual database as viewed by end user

• ERDs depict database’s main components:

– Entities – Attributes

– Relationships

(3)

Entities

• Refers to entity set and not to single entity occurrence

• Corresponds to table and not to row in relational environment

• In Chen and Crow’s Foot models, entity is represented by rectangle with entity’s name

• The entity name, a noun, is written in capital letters

3

(4)

Attributes

• Characteristics of entities

• Chen notation: attributes represented by ovals connected to entity rectangle with a line

– Each oval contains the name of attribute it represents

• Crow’s Foot notation: attributes written in attribute box below entity rectangle

4

(5)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

5

(6)

Attributes (cont’d.)

• Required attribute: must have a value

• Optional attribute: may be left empty

• Domain: set of possible values for an attribute

– Attributes may share a domain

• Identifiers: one or more attributes that uniquely identify each entity instance

• Composite identifier: primary key composed of more than one attribute

– E.g. CRS_CODE, CLASS_SECTION

6

(7)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

7

(8)

Attributes (cont’d.)

• Composite attribute can be subdivided

– E.g. Address, Phone_No

• Simple attribute cannot be subdivided

– E.g. age, gender

• Single-value attribute can have only a single value

– E.g. IC_No

• Multivalued attributes can have many values

– color

8

(9)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

9

(10)

Attributes (cont’d.)

• M:N relationships and multivalued attributes should not be implemented

1. Create several new attributes for each of the original multivalued attributes’ components

e.g. Car_TopColor, Car_BodyColor

2. Create new entity composed of original multivalued attributes’ components

e.g. CAR, CAR_COLOR (refer page 326)

10

(11)

Attributes (cont’d.)

• Derived attribute: value may be calculated from other attributes

– Need not be physically stored within database

(12)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

12

(13)

Relationships

• Association between entities

• Participants are entities that participate in a relationship

• Relationships between entities always operate in both directions

• Relationship name is an active or passive verb

– e.g. takes, employs

• Relationship can be classified as 1:M

• Relationship classification is difficult to establish if only one side of the relationship is known

13

(14)

Connectivity and Cardinality

• Connectivity

– Describes the relationship classification i.e. 1:1, 1:M and M:N

• Cardinality

– Expresses minimum and maximum number of entity occurrences associated with one

occurrence of related entity

• Established by very concise statements known as business rules

14

(15)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

15

(16)

Relationship Participation

• Optional participation

– One entity occurrence does not require

corresponding entity occurrence in particular relationship

• Mandatory participation

– One entity occurrence requires corresponding entity occurrence in particular relationship

• E.g. LECTURER, CLASS

16

(17)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

17

(18)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

18

(19)

Existence Dependence

• Existence dependence

– Entity exists in database only when it is associated with another related entity occurrence (foreign key cannot be null value)

• Existence independence

– Entity can exist apart from one or more related entities

– Sometimes such an entity is referred to as a strong or regular entity

19

(20)

Relationship Strength

• Weak (non-identifying) relationships

– Exists if PK of related entity does not contain PK component of parent entity

• Strong (identifying) relationships

– Exists when PK of related entity contains PK component of parent entity

20

(21)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

21

(22)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

22

(23)

Weak Entities

• Weak entity meets two conditions

– Existence-dependent

– Primary key partially or totally derived from parent entity in relationship

• Database designer determines whether an entity is weak based on business rules

23

(24)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

24

(25)

Relationship Degree

• Indicates number of entities or participants associated with a relationship

• Unary relationship

– Association is maintained within single entity

• Binary relationship

– Two entities are associated

• Ternary relationship

– Three entities are associated

25

(26)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

26

(27)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

27

(28)

Recursive Relationships

• Relationship can exist between occurrences of the same entity set

– Naturally found within unary relationship

28

(29)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

29

(30)

Associative (Composite) Entities

• Also known as bridge entities

• Used to implement M:N relationships

• Composed of primary keys of each of the entities to be connected

• May also contain additional attributes that play no role in connective process

30

(31)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

31

(32)

© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

32

(33)

Developing an ER Diagram

• Database design is an iterative process

– Create detailed narrative of organization’s description of operations

– Identify business rules based on description of operations

– Identify main entities and relationships from business rules

– Develop initial ERD

– Identify attributes and primary keys that adequately describe entities

– Revise and review ERD

(34)

Exercise:

• Draw an ERD for a Taylor college database :

Each department has many lecturers. A lecturer belongs to only one department. Each department offers many different courses, and many lecturers can teach on a single course.

Lecturers can also teach on more than one course. A student

may enroll for many courses offered by different

departments.

(35)

Summary

• Entity relationship (ER) model

– Uses ERD to represent conceptual database as viewed by end user – ERM’s main components:

• Entities

• Relationships

• Attributes

– Includes connectivity and cardinality

notations

(36)

Summary (cont’d.)

• Connectivities and cardinalities are based on business rules

• M:N relationship is valid at conceptual level

– Must be mapped to a set of 1:M relationships

• ERDs may be based on many different ERMs

• UML class diagrams are used to represent the static data structures in a data model

• Database designers are often forced to make design compromises

36

(37)

1. Assignment 3

2. Take home Quiz 2 (Chapter 3)

Due date: 11/10/12, Thursday before 2 p.m.

References

Related documents

The City of Los Angeles Harbor Department (Harbor Department) is requesting approval to enter into an agreement with Neudesic, LLC to implement Microsoft Office

May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.

If llike a reporter, I read her articles. If I have time in the morning, I read the newspaper. Grammar And Beyond 3B. Estados Unidos de america: Cambridge University... U N! T

May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on

While the literature has described successful technician involvement in various aspects of vaccine preparation (e.g., selecting the proper needle, loading the syringe, etc.), only

E.17 Results of a one tailed paired sample t-test performed over the 55 RGB natural sample images, folded using the single channel “pixel” method, to determine if the average

The results were: (1) three items have inappropriate response patterns to the model; (2) all items of the career interest instrument show- ed good item parameter criteria; and (3)

May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.. Chapter 1: