Top Banner
TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS School of Business Administration Gonzaga University Spokane, WA 99258 [email protected]
84

TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

Dec 17, 2015

Download

Documents

Loren Jefferson
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: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-1Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341

Chapter 2Modeling Data in the

Organization

Jason C. H. Chen, Ph.D.

Professor of MIS

School of Business Administration

Gonzaga University

Spokane, WA 99258

[email protected]

Page 2: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-2Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Objectivesh Definition of termsh Importance of data modelingh Write good names and definitions for entities,

relationships, and attributesh Distinguish unary, binary, and ternary relationshipsh Model different types of attributes, entities,

relationships, and cardinalitiesh Draw E-R diagrams for common business situationsh Convert many-to-many relationships to associative

entitiesh Model time-dependent data using time stamps

Page 3: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-3Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

e_id e_name e_address dob date_employed skill … years_employed age1234 John smith 502 Boone

Spokane, WA 99258

1-1-1988

1-1-2005 programming,painting,drawing,

     

5678 Mary Jones 567 SE Main st, Seattle, WA 98059

2-9-87 3-3-2007 Gardening      

                 

                 

EMPLOYEE

EMPLOYEEe_ide_namee_address (street, city, state, zip)dobdate_employed{skill}[years_employed][age]

composite multi-valued

derived/computed

• Should we create “composite” attributes? (see next slide)?

• Should we create “derived/computed” attributes and save physically/ permanently in the database and why?

• How to insert values into “multi-valued” attributes? (later this semester)

Page 4: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-4Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

c_id c_name c_address c_phone    1234 John smith 502 Boone Spokane,

WA 99258     

5678 Mary Jones 567 SE Main St, Seattle, WA 98059

     

3456 Jerry Walker 450 3rd Ave, San Jose, CA 95130

           

CUSTOMER

What is (are) the draw back of creating a CUSTOMER TABLE with “Composite” attribute of c_address?• Can you find out “total number of customers” from state of

Washington?• Can you find out all customers (with their detailed

information) from city of Spokane?• and more …

Page 5: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-5Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Abstraction

h Concealing irrelevant details from the user.–Abstraction is the process of temporarily

ignoring underlying details so we can focus on the big picture of the large problem at hand

Page 6: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-6Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

E/R Modeling

h The E/R model is used to construct a conceptual data model -- a representation of the structure and constraints of a database and is the technology independent.

Page 7: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-7Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Why Data Modeling is Important?

• The characteristics of the data are crucial in the design of the database, programs, and other system components.

• Data are the most complex aspects of many modern MIS - not the processes.

• Data tend to be more stable than the business processes that use that data.

Page 8: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-8Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

SDLC Revisited – Data Modeling is an Analysis Activity (see also Figure 1-7)

Project Identification and Selection

Project Initiation and Planning

Analysis

Physical Design

Implementation

Maintenance

Logical Design

Purpose –thorough analysisDeliverable – functional system specifications

Database activity – conceptual data modeling

Page 9: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-9Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Business Rules

h Statements that define or constrain some aspect of the business

h Assert business structureh Control/influence business behaviorh Are expressed in terms familiar to end usersh Are automated through DBMS software

Page 10: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-10Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

A Good Business Rule is: (Table 2-1)

h Declarative – what, not howh Precise – clear, agreed-upon meaningh Atomic – one statementh Consistent – internally and externallyh Expressible – structured, natural languageh Distinct – non-redundanth Business-oriented – understood by business

people

Page 11: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-11Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

A Good Data Name is:

h Related to business, not technical, characteristics

h Meaningful and self-documentingh Uniqueh Readableh Composed of words from an approved listh Repeatableh Written in standard syntax

Page 12: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-12Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems12

Data Definitions

h Explanation of a term or fact– Term–word or phrase with specific meaning– Fact–association between two or more terms

h Guidelines for good data definition– Gathered in conjunction with systems requirements– Accompanied by diagrams– Concise description of essential data meaning– Achieved by consensus, and iteratively refined

Page 13: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-13Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

E-R Model Constructsh Entities:

– Entity instance: person, place, object, event, concept (often corresponds to a row in a table)

– Entity Type: collection of entities (often corresponds to a table).

– entity type is always SINGULARh Relationships:

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

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

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

(often corresponds to a field in a table)

Page 14: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-14Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Sample E-R Diagram (Figure 2-1)

Page 15: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-15Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Relationship degrees specify number of entity types involved

Entity symbols

A special entity that is also a relationship

Relationship symbols

Relationship cardinalities specify how many of each entity type is allowed

Basic E-R notation (Figure 2-2)

Attribute symbols

Page 16: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-16Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

What Should an Entity Be?h SHOULD BE:

– An object that will have many instances in the database

– An object that will be composed of multiple attributes

– An object that we are trying to model

h SHOULD NOT BE:– A user of the database system – An output of the database system (e.g. a report)

Page 17: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-17Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Inappropriate entities

System user

System output

Figure 2-4 Example of inappropriate entities

Appropriate entities

Page 18: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-18Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Attributes

h Attribute - property or characteristic of an entity type that is of interest to the organization.

h Classifications of attributes:– Required versus Optional Attributes– Simple versus Composite Attribute– Single-Valued versus Multi-valued Attribute– Stored versus Derived Attributes– Identifier Attributes

Page 19: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-19Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Identifiers (Keys)

h Identifier (Key) - An attribute (or combination of attributes) that uniquely identifies individual instances of an entity type

h Simple Key versus Composite Keyh Candidate Key – an attribute that could be a

key…satisfies the requirements for being a key

Page 20: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-20Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Strong vs. Weak Entities, andIdentifying Relationships

h Strong entities – exist independently of other types of entities– has its own unique identifier– identifier underlined with single-line

h Weak entity– dependent on a strong entity (identifying owner)…cannot

exist on its own– does not have a unique identifier (only a partial identifier)– Partial identifier underlined with double-line– Entity box has double line

h Identifying relationship– links strong entities to weak entities

Page 21: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-21Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Strong entity Weak entity

Figure 2-5 Example of a weak identity and its identifying relationship

Page 22: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-22Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Q: (Review Q:#12; p.101) Another example of Weak Entity

Phone Call (see below) is an example of a weak entity because a phone call must be placed by a PERSON. In this simple example, PHONE CALL is related to only one other entity type, thus, it is not necessary to show the identifying relationship; however, if this data model were ever expanded so that PHONE CALL related to other entity types, it is good practice to always indicate the identifying relationship.

Strong entity Weak entity

Page 23: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-23Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Required vs. Optional Attributes

23

Required – must have a value for every entity (or relationship) instance with which it is associated

Optional – may not have a value for every entity (or relationship) instance with which it is associated

Page 24: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-24Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

E-R Model Constructs (Continued)

h Attribute - property or characteristic of an entity type that is of interest to the organization.

h Simple versus Composite Attribute– Fig. 2-7

h Single-Valued versus Multivalued Attribute– Fig. 2-8

h Stored versus Derived Attributes– Fig. 2-8

Page 25: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-25Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Figure 2-7 A composite attribute: An attribute that has meaningful component parts (attributes)

An attribute broken into component parts

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

Multivaluedan employee can have more than one skill

Derivedfrom date employed and current date

Page 26: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-26Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

c_id c_name street city state zip c_phone    1234 John Smith 502

Boone

Spokane WA 99258      

5678 Mary Jones 567 SE Main St

Seattle WA 98059      

3456 Jerry Walker

450 3rd Ave

San Jose CA 95130

         

CUSTOMER (after “breaking” the ‘composite’ address)

• Now we are able to find out “total number of customers” from state of Washington?• HOW?

• We can find out all customers (with their detailed information) from city of Spokane?• HOW?

• and more …

Page 27: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-27Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

E-R Model Constructs (Continued)

h Identifier or Key - An attribute (or combination of attributes) that uniquely identifies individual instances of an entity type.

h Simple Key versus Composite Key (Fig. 2-9)

h Candidate Key

Page 28: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-28Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Figure 2-9 Simple and composite identifier attributes

The identifier is boldfaced and underlined

Page 29: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-29Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

E-R Model Constructs (Continued)

h Criteria for Selecting Identifiers– Will not change in value over the life of each

instance of the entity type.– Will not be NULL.– No intelligent identifiers (containing e.g.

locations or people that might change)– Substitute new, simple (e.g., surrogate

attribute) keys for long, composite keys (e.g., entity type of Game: Game# instead of Home_Team and Visitor_Team)

Page 30: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-30Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

More on Relationshipsh Relationship Types vs. Relationship Instances

– The relationship type is modeled as lines between entity types…the instance is between specific entity instances

h Relationships can have attributes– These describe features pertaining to the association

between the entities in the relationship

h Two entities can have more than one type of relationship between them (multiple relationships)

h Associative Entity–combination of relationship and entity

Page 31: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-31Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Modeling Relationships

h Relationship Type versus Instance– Fig. 2-10

h An associative entity– An entity type that associates the instances that

are peculiar to the relationship between those entity instances.

h Attributes on Relationships – Fig. 2-11

Page 32: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-32Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Figure 2-10 Relationship types and instances

a) Relationship type (Completes)

b) Relationship instances

Page 33: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-33Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems33

Associative Entitiesh An entity - has attributesh A relationship - links entities togetherh When should a relationship with attributes instead be

an associative entity? – All relationships for the associative entity should be many– The associative entity could have meaning independent of

the other entities– The associative entity preferably has a unique identifier, and

should also have other attributes– The associative entity may participate in other relationships

other than the entities of the associated relationship– Ternary relationships should be converted to associative

entities

Page 34: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-34Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Figure 2-11(a) A binary relationship with an attribute Attribute on a relationship (Link Attribute/Associative)

Here, the date completed attribute pertains specifically to the employee’s completion of a course…it is an attribute of the relationship

Page 35: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-35Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Figure 2-11(b) An associative entity (CERTIFICATE)

Associative entity is like a relationship with an attribute, but it is also considered to be an entity in its own right

Note that the many-to-many cardinality between entities in Figure 2-11a has been replaced by two one-to-many relationships with the associative entity

Page 36: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-36Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-11: (b) An associative entity (CERTIFICATE)

Employee_IDCourse_ID

What is an alternative to assign the pk?

Page 37: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-37Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Figure 2-11(c )An associative entity using Microsoft VISIO

Page 38: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-38Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

JustLee E-R Model (Fig. 1-5; p.11 Oracle Text)

PUBLISHERPubID

BOOKSISBN

AUTHORAuthorID

ORDERSOrder#

CUSTOMERSCustomer#

Page 39: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-39Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

JustLee E-R Model (Fig. 1-5; p.11 Oracle Text)

PUBLISHERPubID

BOOKSISBN

AUTHORAuthorID

ORDERSOrder#

CUSTOMERSCustomer#

BOOKAUTHORISBN

AuthorID

ORDERITEMSOrder#Item#

Page 40: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-40Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

JustLee E-R Model (Fig. 1-5; p.11 Oracle Text)

PUBLISHERPubID

BOOKSISBN

AUTHORAuthorID

ORDERSOrder#

CUSTOMERSCustomer#

BOOKAUTHORISBN

AuthorID

ORDERITEMSOrder#Item#

PROMOTIONGift

Page 41: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-41Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

JustLee E-R Model (Fig. 1-5; p.11 Oracle Text)

PUBLISHERPubID

BOOKSISBN

AUTHORAuthorID

ORDERSOrder#

CUSTOMERSCustomer#

BOOKAUTHORISBN

AuthorID

ORDERITEMSOrder#ISBN

PROMOTIONGift

Page 42: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-42Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Entity Type /Entity(attributes)

Entity Instance

Value

Object

E-R Model vs. O-O Model

A collection of entities that share common properties or characteristics

A single occurrence of an entity type/class

ClassAttributes +operations

Page 43: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-43Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Entity Type /Entity(attributes)

Entity Instance

Value

Object

E-R Model vs. O-O Model

A collection of entities that share common properties or characteristics

A single occurrence of an entity type/class

ClassAttributes +operations

Page 44: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-44Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Break ! (Ch. 2 - Part I)In class exercise - #7 (p. 103); - #11 (a-c) [Part II] - cardinalityHW - 1). #10; p. 103 [Draw ER-D (use Word/Visio) ]-2) ER for Northwoods University database (bring a hardcopy to me next class)

Page 45: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-45Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Relationships

h Degree of a Relationship - number of entity types that participate in it (Fig. 2-12)– Unary (or Recursive) Relationship

(degree 1)Bill-of-Materials (Fig. 2.12; 2-13)

– Binary Relationship(degree 2)

– Ternary Relationship (degree 3)

Page 46: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-46Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Cardinality of Relationships

h One – to – One– Each entity in the relationship will have exactly one

related entity

h One – to – Many– An entity on one side of the relationship can have many

related entities, but an entity on the other side will have a maximum of one related entity

h Many – to – Many– Entities on both sides of the relationship can have many

related entities on the other side

Page 47: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-47Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Degree of relationships – from Figure 2-2

One entity related to another of the same entity type

Entities of two different types related to each other

Entities of three different types related to each other

Page 48: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-48Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-12: Example of relationships of different degrees

(a) Unary relationships

Page 49: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-49Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-12: (b) Binary relationships

Page 50: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-50Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

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

c) Ternary relationship

Note: a relationship can have attributes of its own

Page 51: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-51Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

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

c) Ternary relationship

Note: a relationship can have attributes of its own

Page 52: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-52Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-18: Cardinality constraints in a ternary relationship

v_idv_id

p_id

p_id w_idw_id

Page 53: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-53Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-13: Representing a bill-of -materials structure

(a) Many-to-many relationship

Page 54: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-54Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-13: (b) Two instances

Page 55: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-55Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-13 (c ) : An associative entity - bill of materials structure

This could just be a relationship with attributes…it’s a judgment call

Page 56: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-56Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-14: Ternary relationships as an associative entity

Page 57: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-57Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Relationship degrees specify number of entity types involved

Entity symbols

A special entity that is also a relationship

Relationship symbols

Relationship cardinalities specify how many of each entity type is allowed

Basic E-R notation (Figure 2-2)

Attribute symbols

Page 58: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-58Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Figure 2-15a and 2-15b Multivalued attributes can be represented as relationships/Associative Entity

simple

composite

Page 59: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-59Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-15: Using relationships and entities to link related attributes(c) Composite attribute of data shared with other entity types

Page 60: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-60Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Cardinality Constraintsh Cardinality Constraints - the

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

h Minimum Cardinality– If zero, then optional– If zero or more, then optional

many– If one or more, then

mandatory many– Mandatory One - when min &

max both = 1h Maximum Cardinality

– The maximum number

Page 61: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-61Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-16: Introducing cardinality constraint

(a) Basic relationship

(a) Relationship with cardinality constraints

Page 62: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-62Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

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

Page 63: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-63Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

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

(4)

Page 64: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-64Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

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

c) Optional cardinalities

A person is married to at most one other person, or may not be married at all

Page 65: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-65Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-18: Cardinality constraints in a ternary relationship

Each vendor can supply many parts to any number of wareshouses, but need not supply any parts.

Each part can be supplied by any number of vendors to more than one WH, but each part must supplied by at least one vendor to a WH.

Each WH can be supplied with any number ofparts from more than one vendor, but each WHmust be supplied with at least one part

Page 66: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-66Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Relationships

h Modeling Time-Dependent Data– Time Stamps: a time value that is associated with

a data value (Fig. 2-19; 2-20)– managing time-dependent data is inadequate

using current data models --> data warehousing

h Multiple Relationship: Business Rules– more than one relationship between the same

entity types (Fig. 2-21)

Page 67: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-67Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Figure 2-19 Simple example of time-stamping

This attribute is both multivalued and composite

Page 68: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-68Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-20: (a) E-R diagram not recognizing product reassignment

Fig. 2-20: (b) E-R diagram recognizing product reassignment

Page 69: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-69Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-20: Pine Valley Furniture product database(c) E-R diagram with associative entity for product assignment to product line over time

Page 70: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-70Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-20: (a) E-R diagram not recognizing product reassignment

PRODUCTLINE

PRODUCT ORDER

How to reflect product line changed over time?

Sales Product Product-Line

$50,000 P B

$40,000 P A(out of $50,000)

Assigned

Placed

In the middle of year, due to a reorganization of the sales function some products are reassigned to different product lines

Page 71: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-71Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-20: Pine Valley Furniture product database

(b) E-R diagram recognizing product reassignment

Sales Product Product-Line$50,000 P B$40,000 P A(out of $50,000)$10,000 P B$40,000 P A(out of $50,000)

Solution: adding a new relationship of “Sales_for_product_line”

Page 72: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-72Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-20: Pine Valley Furniture product database(c) E-R diagram with associative entity for product assignment to product line over time

Page 73: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-73Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-21: Examples of multiple relationships

(a) Employees and departments

Entities can be related to one another in more than one way

Page 74: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-74Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Here, minimum cardinality constraint is 2, what’s for?

Fig. 2-21: (b) Professors and courses (fixed upon constraint)

??

A New Business Rule:An instructor who isscheduled to teach a course must be qualifiedto teach that course?? (next chapter)

At least two professors must be qualified to teach each course. Each professor must be qualified to teach at least one course.

Page 75: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-75Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Database Processing: SQLShowing Product InformationList all details for the various computer desks that are stocked by the company?

SELECT *FROM PRODUCTWHERE product_Description LIKE “Computer Desks%”;

Showing Customer Order StatusHow many orders have we received from “Value Furniture?

SELECT COUNT (Order_ID)FROM ORDERWHERE Customer_ID = (SEELCT Customer_ID FROM CUSTOMER WHERE Customer_Name = “Value Furniture”);

Page 76: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-76Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-22: E-R diagram for Pine Valley Furniture Company(A Conceptual Data Model)

TOP - DOWN Approachvs.

BOTTOM - UP Approach

Page 77: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-77Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-22: Microsoft Visio

Notation for Pine Valley Furniture

E-R diagram

Different modeling software tools may have different notation for the same constructs

Page 78: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-78Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-22: E-R diagram for Pine Valley Furniture Company

Page 79: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-79Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Fig. 2-23: Two user views for Pine Valley Furniture

(a) User View 1: Orders for customers

(b) User View 2: Orders for products

Page 80: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-80Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems80

Different people have different views of the database…these are the external schema

The internal schema is the underlying design and implementation`

Figure 1-12 Three-schema architecture

Page 81: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-81Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Figure 1-12: Three-schema database architecture

ExternalView

InternalView

Meta-data/Repository/

D.D.

E/R, OO …

Relations

Database

Ch. 4

Ch. 2,3,4

Ch. 5

Page 82: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-82Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

The Entity Relationship (E-R) Model

Congratulation !!

You have just learned one of the most important modeling concept (E-R) for developing the data base systems.

Page 83: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-83Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

MVC_Hospital HWPhase I - Logical Design Phase

Draw a entity-relationship diagram (enterprise model) for Mountain View community Hospital, based on the narrative description of the case and this handout (but the entities are from the five (5) figures/reports shown in the assignment sheet). You should create a file and turn in with a hardcopy (file name: MVC_Phase I_ERD_Lname_Fname.docx) contains the following materials:1. Read and employ materials from chapters 1 and 22. Include entities, associations (with detail multiplicity), and attributes.3. Determine and draw the order of entering data

Upload ONLY the .docx file to the Blackboard (under “Assignments”) with the following file name: bmis441_MVC-Phase I_Lastname_Firstname.docx

Page 84: TM 3-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, BMIS341 Chapter 2 Modeling Data in the Organization Jason C. H. Chen, Ph.D. Professor of MIS.

TM 3-84Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems

Problems and ExercisesIn class exercise - #11 (a-c), p.103 [ Cardinality] - #13 [Review Questions, p.103]

HW (using Visio)1. #20 ( p.106)- turn in with hardcopy2. MVC mini project- Phase I (ERD both hard and soft copies)