15
1 Georgia State University--CIS 850/330 Entity Relationship Modeling Entity-Relationship Diagrams Georgia State University--CIS 850/330 Entity Relationship Modeling Entity-Relationship Diagrams Contents: Data Modeling User Views Entities/ Entity Sets Attributes Entity-Relationship Diagrams (ERDs) Finding Entities and Relationships English Grammar Rules Registration Example Student Registration Course Enrollment Grade Report Relationship Attributes Extended ERD Note: The Entity-Relationship Diagrams presented in this class are based on James Martin’s Information Enginnering approach.

Ch 3 2 ERDModlgMinMax

  • Upload
    amr

  • View
    220

  • Download
    0

Embed Size (px)

DESCRIPTION

database

Citation preview

Page 1: Ch 3 2 ERDModlgMinMax

1

Georgia State University--CIS 850/330 Entity Relationship Modeling

Entity-Relationship Diagrams

Georgia State University--CIS 850/330 Entity Relationship Modeling

Entity-Relationship Diagrams

Contents:

Data ModelingUser ViewsEntities/ Entity SetsAttributesEntity-Relationship Diagrams (ERDs)Finding Entities and RelationshipsEnglish Grammar RulesRegistration Example

Student RegistrationCourse EnrollmentGrade Report

Relationship AttributesExtended ERD

Note: The Entity-Relationship Diagrams presented in thisclass are based on James Martin’s Information Enginneringapproach.

Page 2: Ch 3 2 ERDModlgMinMax

2

Georgia State University--CIS 850/330 Entity Relationship Modeling

Design ApproachSteps:

1. Model User View

2. Normalize these relations

3. Represent all keys

4. Merge the result of the previous steps into the cumulative design.

User View

Collection of Tables

Collection of BCNF Tables

Collection of BCNF Tables with Keys Represented

New Cumulative Design

Old Cumulative Design

Georgia State University--CIS 850/330 Entity Relationship Modeling

Model User View

Advantages of Data Modeling:

+ Data Analysis vs. Process Analysis

+ Graphical Models vs. Prose

+ “Data is more stable than processes.”

Page 3: Ch 3 2 ERDModlgMinMax

3

Georgia State University--CIS 850/330 Entity Relationship Modeling

User Views

A user view is the view of the data that is necessaryto support the operations of a particular user.

Example: Wells Junior College

User View #1 -- Registration

User View #2 -- Class Enrollment

User View #2 -- Grade Reporting

Georgia State University--CIS 850/330 Entity Relationship Modeling

Entities/ Entity Set

An entity is a person, place, object, event, or concept about which the organization wishes to record data.

Rules: An entity . . .1. Must be within the scope of the system2. Must have at least one non-key attribute

An entity type is a collection of entities witha similar data structure.

Page 4: Ch 3 2 ERDModlgMinMax

4

Georgia State University--CIS 850/330 Entity Relationship Modeling

Entity Type -- Examples

Customer

Product

Supplier

Georgia State University--CIS 850/330 Entity Relationship Modeling

Entity Instance (Entity)

Sally Smith

PS/2,model 60,ID#Qty-on-Hand

Panasonic, model 82sm

Allen Baker

Page 5: Ch 3 2 ERDModlgMinMax

5

Georgia State University--CIS 850/330 Entity Relationship Modeling

Attributes

An attribute is a property of an entity that we choose to record.

Attributes of Customer entity:

Social security numberNameAddressDate of birth

Georgia State University--CIS 850/330 Entity Relationship Modeling

Entity-Relationship Diagrams

An Entity-Relationship Diagram (ERD) is a graphicalportrayal of entities and their relationships.

Entity types are shown in rectangles andrelationship types are shown as the lines that connect related entity types.

Employee ProjectWorks for

Page 6: Ch 3 2 ERDModlgMinMax

6

Georgia State University--CIS 850/330 Entity Relationship Modeling

Entity-Relationship Diagrams (ERDs)

Entity types Class

Student ClassEnrolls in

is taken by

Relationships are named; sometimes in both directions.

Student

Georgia State University--CIS 850/330 Entity Relationship Modeling

Many represenation forms: Chen (min/max), Booch, Codd/Yordon, Crows feet...

Default and prefered method in SA is Crows feet

Difference between Min/Max and Crows feet:– how cardinality and participation is expressed.

– the existence of the Assocation Diamond

Relationship: Cardinalities and Participation

Page 7: Ch 3 2 ERDModlgMinMax

7

Georgia State University--CIS 850/330 Entity Relationship Modeling

Chen’s (Min/Max)Notation:Cardinalities and Participation

Read in terms of the entity instance you are leaving. i.e. E1

E1 E2R(min, max) (min, max)

Participation 0 -- Partial 1 -- Total (mandatory)

Cardinality 1 -- one M -- more than one

Relationship diamond

Georgia State University--CIS 850/330 Entity Relationship Modeling

Chen’s (Min/Max)Notation: anexample

Read: A Customer may participate in from zero to many relationships

Customer OrderPlaces(0, M) (1, 1)

Participation 0 -- Partial 1 -- Total (mandatory)

Cardinality 1 -- one M -- more than one

Relationship

Page 8: Ch 3 2 ERDModlgMinMax

8

Georgia State University--CIS 850/330 Entity Relationship Modeling

Chen’s (Min/Max)Notation: anexample

Instructor OfficeAssign(1,1) (0,1)

DepartmentWork_for

(1,1)

(0,m)

Teach

(0,m)

(0,m)

Course

Date

Language

Emp#

NameFName

MInit LName

Time

Location

Date

Georgia State University--CIS 850/330 Entity Relationship Modeling

Crows Foot Notation

Read in terms of the relationship with which an entity instance is participating

Participation and Cardinality are shown by the crows feet.

Customer OrderPlaces

Read: A customer places (or may place) zero to

many orders; An order is placed by one and

only one Customer

Page 9: Ch 3 2 ERDModlgMinMax

9

Georgia State University--CIS 850/330 Entity Relationship Modeling

A is related to one and only one B

A is related to zero or one B

A is related to one or more B

A is related to zero, one or more B

A is related to more than one B

Relationship Cardinalities

A

A

A B

B

BA

A

B

B

Georgia State University--CIS 850/330 Entity Relationship Modeling

Cardinality Examples

Employee Dependent Claims

is-claimed-by

Instructor Class Teaches

is-taught-by

Customer OrderPlacesIs-Placed-by

Page 10: Ch 3 2 ERDModlgMinMax

10

Georgia State University--CIS 850/330 Entity Relationship Modeling

Finding Entities and Relationships

1. Identify the system informationa. User interviewsb. Paper and screen documentsc. Previous system documentation

2. Identify entitiesa. Heuristicsb. Analysis of English grammar -->

Entity-Relationship Diagramsc. Normalization process

Georgia State University--CIS 850/330 Entity Relationship Modeling

Entity Identification: English Grammar - Rule #1

English ERD

Proper Noun Entity (“Name” of an Entity)

Common Noun Entity or Entity-Type

Transitive Verb M-ary Relation (M>1)

Intransitive Verb Unary Relationship or Attribute Value

Adjective Attribute of an Entity

Adverb Attribute of a Relationship

Page 11: Ch 3 2 ERDModlgMinMax

11

Georgia State University--CIS 850/330 Entity Relationship Modeling

Convert any sentence in the following form:“There are . . . X in Y”

into“Y has . . . X”

Entity Identification: English Grammar - Rule #1

Example: X Y“There are more than 200 employees in every department.”

Y X “Every department has more than 200 employees.”

Department Employee

Georgia State University--CIS 850/330 Entity Relationship Modeling

English Grammar - 3

If the English sentence says, “The X of Y is Z”

Rule #3: Y is an Entity

Rule #4: X is either an Attribute or an Entity, depending on what type of “Z” it is.

Rule #5a: If “Z” is a proper noun, then X is aRelationship between Y and Z

Rule #5b: Otherwise, X is an Attribute of Y

Page 12: Ch 3 2 ERDModlgMinMax

12

Georgia State University--CIS 850/330 Entity Relationship Modeling

Grammar - 3 (Examples)

The birthdate of the student is 10/22/71.(x) (y) (z)

Attribute Entity not a proper noun

Student Birthdate * “10/22/71”

The advisor of John Smith is Dr. Greene. (x) (y) (z)Relationship Proper noun

Student * Advisor *

Georgia State University--CIS 850/330 Entity Relationship Modeling

ERD for Student Registration

Student

Advisor

Course

Instructor

Advises/is advised by

Enrolls in

is taken by

Is taught by/teaches

* Note: Attributes should be specified for each entity-type

Page 13: Ch 3 2 ERDModlgMinMax

13

Georgia State University--CIS 850/330 Entity Relationship Modeling

ERD for Course Enrollment

Student Course

Instructor

Enrolls in

is taken by

Is taught by/teaches

* Note: Attributes should be specified for each entity-type

Georgia State University--CIS 850/330 Entity Relationship Modeling

ERD for Grade Report

Student

Advisor

Course

Instructor

Advises/is advised by

Enrolls in

is taken by

Is taught by/teaches Grade

* Note: Attributes should be specified for each entity-type

Earns

Applies to

Page 14: Ch 3 2 ERDModlgMinMax

14

Georgia State University--CIS 850/330 Entity Relationship Modeling

Relationship Attributes

If a Relationship has Attributes,

For example:

Works for

• An Employee is assigned to a project for a certain % of time.• An Employee has a particular role for each project he/she

works on (e.g., programmer, analyst, project manager, etc.)

Employee Project

Georgia State University--CIS 850/330 Entity Relationship Modeling

Relationship-Entity

Employee Project

Then the Relationship becomes a Relationship-Entity:

Project-Assignment

Page 15: Ch 3 2 ERDModlgMinMax

15

Georgia State University--CIS 850/330 Entity Relationship Modeling

Extended Model

* Note: Attributes should be specified for each entity-type

Student Course

Advises/is advised by

Enrolls in

is taken by

Is taught by/teaches

Grade

Department

Earns Applies to

Employs

Works for Faculty

Advisor

Instructor

Georgia State University--CIS 850/330 Entity Relationship Modeling

Review

Definitions:

User ViewEntity, Entity-TypeRelationshipCardinality

Using English Grammar to identifyEntities and Relationships

Entity-Relationship Diagrams