Top Banner
CHAPTER 2: CHAPTER 2: MODELING DATA IN THE MODELING DATA IN THE ORGANIZATION ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi
23

CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Dec 22, 2015

Download

Documents

Linette Edwards
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

CHAPTER 2:CHAPTER 2:MODELING DATA IN THE MODELING DATA IN THE ORGANIZATIONORGANIZATION

© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

1

Modern Database Management11th Edition

Jeffrey A. Hoffer, V. Ramesh, Heikki Topi

Page 2: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

OBJECTIVESOBJECTIVES

Define termsDefine terms Write good names and definitions for Write good names and definitions for

entities, relationships, and attributesentities, relationships, and attributes Model different types of attributes and Model different types of attributes and

entities, entities, Introduce the concept of relationships, Introduce the concept of relationships,

and cardinalitiesand cardinalities Draw E-R diagrams for common business Draw E-R diagrams for common business

situationssituations

2

Page 3: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

A GOOD DATA NAME IS:A GOOD DATA NAME IS:

Related to bRelated to business, not technical, usiness, not technical, characteristicscharacteristics

Meaningful and self-documentingMeaningful and self-documenting UniqueUnique Written in standard syntaxWritten in standard syntax

Data DefinitionsData Definitions Provide a concise description of Provide a concise description of

essential data meaningessential data meaning

3

Page 4: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

E-R MODEL E-R MODEL CONSTRUCTSCONSTRUCTS

Entities:Entities: Entity instance–person, place, object, event, concept Entity instance–person, place, object, event, concept

(often corresponds to a row in a table)(often corresponds to a row in a table) Entity Type–collection of entities (often corresponds to Entity Type–collection of entities (often corresponds to

a table)a table) Relationships:Relationships:

Relationship instance–link between entity instances Relationship instance–link between entity instances (corresponds to primary key-foreign key equivalencies in (corresponds to primary key-foreign key equivalencies in related tables)related tables)

Relationship type–category of relationship…link between entity Relationship type–category of relationship…link between entity typestypes

Attributes:Attributes: Properties or characteristics of an entity or relationship Properties or characteristics of an entity or relationship

type (often corresponds to a field in a table)type (often corresponds to a field in a table)

4

Page 5: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

ENTITY TYPE AND ENTITY ENTITY TYPE AND ENTITY INSTANCESINSTANCES

6

Page 6: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

AN ENTITY…AN ENTITY…

SHOULD BE:SHOULD BE: An object that will have many An object that will have many

instances in the databaseinstances in the database An object that will be composed of An object that will be composed of

multiple attributesmultiple attributes An object that we are trying to modelAn object that we are trying to model

SHOULD NOT BE:SHOULD NOT BE: A user of the database system A user of the database system An output of the database system An output of the database system

(e.g., a report)(e.g., a report)

7

Page 7: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall8

Inappropriate entities

System System useruser

System System outputoutput

Figure 2-4 Example of inappropriate entities

Appropriate entities

Page 8: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

ATTRIBUTESATTRIBUTES

Attribute–property or characteristic of Attribute–property or characteristic of an entity or relationship typean entity or relationship type

Classifications of attributes:Classifications of attributes: Required versus Optional AttributesRequired versus Optional Attributes Simple versus Composite AttributeSimple versus Composite Attribute Single-Valued versus Multivalued Single-Valued versus Multivalued

AttributeAttribute Stored versus Derived AttributesStored versus Derived Attributes Identifier AttributesIdentifier Attributes

9

Page 9: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

SIMPLE VS. COMPOSITE SIMPLE VS. COMPOSITE ATTRIBUTESATTRIBUTES

Composite attributeComposite attribute – An attribute that has – An attribute that has meaningful component parts (attributes)meaningful component parts (attributes)

10

The address is broken into component parts

Figure 2-7 A composite attribute

Page 10: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

11

Figure 2-8 Entity with multivalued attribute (Skill) and derived attribute (Years Employed)

Multivaluedan employee can have more than one skill

DerivedCalculated from date employed and current date

Multi-valued and Derived Multi-valued and Derived AttributesAttributes

Multivalued – may take on more than one value for a given entity (or relationship) instance

Derived – values can be calculated from related attribute values (not physically stored in the database)

11Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

Page 11: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

IDENTIFIERS (KEYS)IDENTIFIERS (KEYS)

Identifier (Key)–an attribute (or Identifier (Key)–an attribute (or combination of attributes) that combination of attributes) that uniquely identifies individual uniquely identifies individual instances of an entity typeinstances of an entity type

Simple versus Composite IdentifierSimple versus Composite Identifier Candidate Identifier–an attribute Candidate Identifier–an attribute

that could be a key…satisfies the that could be a key…satisfies the requirements for being an identifierrequirements for being an identifier

12

Page 12: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

CRITERIA FOR IDENTIFIERSCRITERIA FOR IDENTIFIERS

Choose Identifiers thatChoose Identifiers that Will not change in valueWill not change in value Will not be nullWill not be null

Avoid intelligent identifiers (e.g., Avoid intelligent identifiers (e.g., containing locations or people that might containing locations or people that might change)change)

Substitute new, simple keys for long, Substitute new, simple keys for long, composite keyscomposite keys

13

Page 13: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

BUSINESS RULESBUSINESS RULES Are statements that define or constrain Are statements that define or constrain

some aspect of the businesssome aspect of the business Are derived from policies, procedures, Are derived from policies, procedures,

events, functionsevents, functions Assert business structureAssert business structure Control/influence business behaviorControl/influence business behavior Are expressed in terms familiar to end usersAre expressed in terms familiar to end users Are automated through DBMS softwareAre automated through DBMS software

14

If possible

Page 14: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

E-R MODEL E-R MODEL CONSTRUCTSCONSTRUCTS

Entities:Entities: Entity instance–person, place, object, event, concept (often Entity instance–person, place, object, event, concept (often

corresponds to a row in a table)corresponds to a row in a table) Entity Type–collection of entities (often corresponds to a Entity Type–collection of entities (often corresponds to a

table)table) Relationships:Relationships:

Relationship instance–link between entity instances Relationship instance–link between entity instances (corresponds to primary key-foreign key (corresponds to primary key-foreign key equivalencies in related tables)equivalencies in related tables)

Relationship type–category of relationship…link Relationship type–category of relationship…link between entity typesbetween entity types

Attributes:Attributes: Properties or characteristics of an entity or relationship type Properties or characteristics of an entity or relationship type

(often corresponds to a field in a table)(often corresponds to a field in a table)

15

Page 15: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

MODELING RELATIONSHIPSMODELING RELATIONSHIPS

Relationship Types vs. Relationship Relationship Types vs. Relationship InstancesInstances The relationship type is modeled as lines The relationship type is modeled as lines

between entity types…the instance is between entity types…the instance is between specific entity instancesbetween specific entity instances

16

Page 16: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

17

Figure 2-10 Relationship types and instances

a) Relationship type (Completes)

b) Relationship instances

17Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

Page 17: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

18

Sample E-R Diagram (Figure 2-1)

18Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

Page 18: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

20

Degree of relationships – from Figure 2-2

Entities of two different types related to each other

Entities of three different types related to each other

One entity related to another of the same entity type

20Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

Page 19: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

CARDINALITY OF RELATIONSHIPSCARDINALITY OF RELATIONSHIPS

One-to-OneOne-to-One Each entity in the relationship will have exactly Each entity in the relationship will have exactly

one related entityone related entity One-to-ManyOne-to-Many

An entity on one side of the relationship can An entity on one side of the relationship can have many related entities, but an entity on have many related entities, but an entity on the other side will have a maximum of one the other side will have a maximum of one related entityrelated entity

Many-to-ManyMany-to-Many Entities on both sides of the relationship can Entities on both sides of the relationship can

have many related entities on the other sidehave many related entities on the other side

21

Page 20: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

CARDINALITY CONSTRAINTSCARDINALITY CONSTRAINTS Cardinality Constraints—the number of Cardinality Constraints—the number of

instances of one entity that can or must instances of one entity that can or must be associated with each instance of be associated with each instance of another entityanother entity

Minimum CardinalityMinimum Cardinality If zero, then optionalIf zero, then optional If one or more, then mandatoryIf one or more, then mandatory

Maximum CardinalityMaximum Cardinality The maximum numberThe maximum number

22

Page 21: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

23

Figure 2-17 Examples of cardinality constraints

a) Mandatory cardinalities

A patient must have recorded at least one history, and can have many

A patient history is recorded for one and only one patient

23Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

Page 22: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

24

Figure 2-17 Examples of cardinality constraints (cont.)

b) One optional, one mandatory

An employee can be assigned to any number of projects, or may not be assigned to any at all

A project must be assigned to at least one employee, and may be assigned to many

24Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall

Page 23: CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.

25

Figure 2-12 Examples of relationships of different degrees (cont.)

b) Binary relationships

25Chapter 2 © 2013 Pearson Education, Inc.  Publishing as Prentice Hall© 2013 Pearson Education, Inc.  Publishing as Prentice Hall