(c) Robert Morris University 2006 Self-paced Learning and On-line Teaching of Entity-Relationship...

Preview:

Citation preview

(c) Robert Morris University 2006

Self-paced Learning and On-line Teaching of

Entity-Relationship Modeling

Peter Y. WuJeanne M. BaughValerie J. Harvey

Nov 2, 2006

A plan to teach ER Modeling

Part of an undergraduate Database course IS 2002 Model Curriculum requirements 6 weeks out of 15 – for a 3 credits course Designed for flexibility to cater to students

• minimize need for face-to-face contact• facilitate for self-study and on-line learning

For self-paced learning and on-line teaching Rely more on the students’ self-discipline

Nov 2, 2006

The (15 weeks) Schedule

Week(s) Topic

1 to 6 Relational Data Model and Use of SQL

7 and 8 Normal Forms and Normalization (for design evaluation)

9 to 14 Entity-Relationship Modeling and database design

15 Database Systems: administration and management

Nov 2, 2006

A plan to teach ER Modeling

For 6 weeks … (out of the 15-weeks course) The plan covers:

Fundamentals of Entity-Relationship Modeling Application to the design of Relational Schema Extended ER Modeling with Specialization Optional alternative notations:

Bachman UML (automated tools) … to be added

Nov 2, 2006

19 Modules for ER Modeling

0 Introduction to ER modeling

1 Entities and Attributes

2 Types of Attributes

3 Key and Key Attributes

4 Tables for Entity Sets

5 The Index Card Analogy

6 Relationship and

Relationship Instances

7 Participation Constraint

8 Cardinality Constraint

9 Design Rules and Tips

10 Tables for Relationship Sets

11 Weak Entities and

Dependency Relationship

12 Tables for Weak Entity Sets

13 Creating Entity Sets in Design

14 Specialization and Generalization

15 Tables for Extended ER Model

16 (min,max) Structural Constraint

17 Bachman Notation

18 ER Diagram using UML

M0: Introduction to ER Modeling

M1: Entity and Attributes

M2: Types of Attributes M3: Key and Key Attributes

M4:Tables for Entity Sets

M5: Index Card Analogy

M6: Relationship and Relationship Instances

M7: Participation Constraint M8: Cardinality Constraint

M16: (min,max) NotationM9: Design Rules

M10:Tables for Relationship Sets

M11:Weak Entities

M12: Tables for Weak Entity Sets

M13: Creating Entity Sets

M14: Specialization / Generalization

M15: Tables for Extended ER Model

M17: Bachman Notationoptional

M18: ER Diagram in UMLoptional

ER Modeling: 19 ModulesDependency Graph

Nov 2, 2006

19 Modules for ER Modeling

0 Introduction to ER modeling

1 Entities and Attributes

2 Types of Attributes

3 Key and Key Attributes

4 Tables for Entity Sets

5 The Index Card Analogy

6 Relationship and

Relationship Instances

7 Participation Constraint

8 Cardinality Constraint

9 Design Rules and Tips

10 Tables for Relationship Sets

11 Weak Entities and

Dependency Relationship

12 Tables for Weak Entity Sets

13 Creating Entity Sets in Design

14 Specialization and Generalization

15 Tables for Extended ER Model

16 (min,max) Structural Constraint

17 Bachman Notation

18 ER Diagram using UML

Nov 2, 2006

Module 0: Intro to ER modeling

1. Tool for database system analysis and design.

2. Simple case study as an example.

3. ER model captures the way business works with data.

4. ER diagram expresses the model, i.e., the schema.

Entity-Relationship Model

Briefly introduced… Entity – thing Relationship – nature of association between

things (entities) Entity-Relationship Modeling – a way to

model the real world, as things, and how the things are associated together.

Entity-Relationship Diagram – we present our model graphically.

Entity-Relationship Model

Entity – a specific thing, physical or conceptual. Example: the sun, the number one, the car model Mustang, the man Adam.

Attributes and Values – to model an entity by its properties (e.g. color: red)

Relationship – the way specific things are associated in the nature of a relationship. Example: Adam and Eve as husband and wife. The association of related entities together constitute a relationship instance.

Entity-Relationship DiagramExample… (Info System for the university registrar) There are these entities: courses and instructors. Each instructor has a name and a phone number. Each course has course number and title. Instructors teach courses…

instructor

name

phone

course

number

title

teaches

Illustration: the data … Instructor P. Wu, phone x9420, teaches the course

IS4240, Database Management System. Instructor P. Laverty, phone x9429, teaches the course

IS4244, Document Processing. . . .

teachesinstructors

name: P Lavertyphone: x9429

name: P. Wuphone: x9420

name: …phone: xxxxx

courses

number: 4240title: DB Mgt Sys

number: 4244title: Doc Proc

number: 4249title: E-Business

Schema: conceptual to relational

TEACHES

Name Number

INSTRUCTOR

Name Phone

instructor

name

phone

course

number

title

teaches

COURSE

Number Title

Nov 2, 2006

Module 1: Entities and Attributes

1. Modeling things as entities and their attributes.

2. Attribute names and attribute values.

3. Entity as something specific, physical or conceptual.

4. Entity, entity type, and entity set.

Nov 2, 2006

Module 2: Types of Attributes

1. Simple and composite attributes

2. Stored and derived attributes

3. Single and multiple valued attributes

4. Optional attributes

Nov 2, 2006

Module 3: Key and Key Attributes

1. The uniqueness constraint in ER modeling.

2. Key as a collection of attributes

3. Key, super key, and candidate key

4. Different candidate keys for the same entity set.

Nov 2, 2006

Module 4: Tables for Entity Sets

1. Relational table for an entity set.

2. Primary key and secondary keys.

3. Optional attribute and column allowing null.

4. Extra table for multi-valued attribute.

Nov 2, 2006

Module 5: The Index Card Analogy

1. Entity set as a deck of index cards.

2. Entity set name and attribute names are printed on each card.

3. A card with attribute values filled in represents the entity.

Example… Entity Set in ER Model

BOOK

Database Systemby G. Riccardi

Question: are we talking about a book (published) or a copy (printed) ?

Example… Entity Set with Attributes

… think of each entity set as a deck of cards.

Each card is labeled with entity type, and the same attributes, being of the same type.

Each card has its own specific values for each of the attributes, representing a specific entity.

course

title: E-Businessnumber: 4249

course

title: Doc Procnumber: 4244

course

title: DBMSnumber: 4240

student

name: Pat Wongmajor: Comp Sci

student

name: Lily Smithmajor: Psychology

student

name: John Doemajor: Info Sci

Relational Table from Entity Set

StudentName

Major

Student

Name Major

John Doe Info Sci

Lily Smith Psychology

Pat Wong Comp Sci

. . . . . .

Note that the ER Model conveys the conceptual structure of information, not the data values.

Nov 2, 2006

Module 6: Relationship and Relationship Instances

1. Binary relationship in ER modeling.

2. Relationship set, relationship instance.

3. Relationship attributes.

4. Relationship has NO key attribute. Why?

Relationship Instances…

course

title: E-Businessnumber: 4249

course

title: DB Mgt Sysnumber: 4240

teacher

name: P.Wuphone: x 9427

teacher

name: P. Lavertyphone: x 9420

teaches

(P.Wu, 4240)

teaches

(P. Laverty, 4249)

Relationship Set

Nov 2, 2006

Module 7: Participation Constraint

1. Total participation.

2. Partial participation.

Nov 2, 2006

Module 8: Cardinality Constraint

1. 1-to-1 cardinality ratio.

2. 1-to-many and many-to-1 cardinality ratios.

3. Many-to-many cardinality ratio.

4. Cardinality ratios working with participation constraints.

5. Properly interpreting cardinality constraints.

Nov 2, 2006

Module 9: Design Rules and Tips

1. Two entity sets can connect only thru a relationship.

2. Attribute value should never imply a relationship between entities; relationship should be explicit in the model.

3. Relationship should never connect with another relationship; at least one of them can be treated as an entity set.

Entity Sets

Do NOT connect one Entity Set to another.

employee officeX

Example: Explicit Relationship!We should model relationship explicitly and avoid

using attributes to imply a relationship.

employee

name

room#

phone

e-mail

officeoccupies

office

occupantX X

Example: Explicit Relationship.

So that we may also keep track of changes in the near future within our database…

employee

name

room#

phone

e-mail

officeoccupies

effective date

Example: relationship or entity?

Men and Women members of a skating club are going to pair up in a competition….

Man Womanpairs up with

pair number

Example: relationship or entity?

Each pair will compete and get rated by three judges, each giving a score…

Judge Pairrates

score

Example: relationship to relationship?

A relationship is the association of entities, should not be that of other relationships!

Judge rates

Man Womanpairs up with

score

pair number

?

Example: relationship to entities!

Judge rates

Man Woman

score

pair number

Pair

Nov 2, 2006

Module 10: Tables for Relationship Sets

1. Additional table is needed for M-to-M relationship.

2. M-to-1 relationship: table at the “1” side may be extended to carry information for the relationship.

3. 1-to-1 relationship: may extend either side, or both sides.

4. Use of foreign keys in these tables.

5. Allowing null values for partial participation.

Nov 2, 2006

Module 11: Weak Entities and Dependency Relationships

1. Entities dependent on its relationships for identity.

2. Symbol for entity set and dependency relationships.

3. When dependency relationship is 1-to-1…

4. The need for partial key when dependency relationship is M-to-1.

Example: Weak Entity Set

Consider modeling the information in a library. We have the entity set Book for books…

Book

title

author

year

Call No

Example: Weak Entity Set Members of the library may borrow books: we have a

relationship between Book and Member…

Member Bookloan

due date

• Can we have two different members borrowing the same book? (More accurately stated: two different copies of the same book?)

PROBLEM!

Example: Weak Entity Set

The Book entity set: does each entity represent a book? OR a copy of a book? Need copy number!

Book Copy

title

author

year

Call No + Copy No

Example: Weak Entity Set We need to deal with two different concepts in the

library: book, and copy of a book:

Book CopyBook

title title

authorauthor

call no call no

copy no

Example: Weak Entity Set With both Book and Book Copy, we can properly

model the relationships with Member.

Book Copy

Book

Member expected date

due date

reserves

borrows(0,4) (0,1)

(0,*) (0,*)

Example: Weak Entity Set We duplicate a good deal of information in the

entity sets: Book and Book Copy – the two should be related! (implied relationship)

Book CopyBook

title title

authorauthor

call no call no

copy no

copiesN1

Example: Weak Entity Set We will allow a weak entity set for Book Copy, with partial

key copy no (underlined by dash), and a dependency relationship copies to a strong entity set.

Book CopyBook

title

author

call no

copy no

copiesN1

Nov 2, 2006

Module 12: Tables for Weak Entity Sets

1. Weak entity set translates into a table in the same way (as strong entity set).

2. Key for the weak entity set table.

3. The need to combine with partial key.

4. Extending the table to take care of attributes of the dependency relationship.

Nov 2, 2006

Module 13: Creating Entity Sets in Design

1. Entity versus attribute: an attributive entity.

2. Entity versus relationship: an associative weak entity.

3. Weak entity with multiple dependency relationships.

Nov 2, 2006

Module 14: Specialization and Generalization: Extended ER Modeling

1. Referring to a subset of an entity set: specialization in Extended ER modeling.

2. Super class and sub-class, with inheritance.

3. Total and partial specialization.

4. Disjoint and overlap specialization.

5. Generalization in Extended ER modeling: the reverse of specialization.

Nov 2, 2006

Module 15: Tables for the Extended ER Model

1. Table for superclass – same as an entity set.

2. Table for subclass: keys inherited.

3. Foreign key in subclass tables.

4. Special cases when specialization is total and disjoint (superclass table unnecessary).

Nov 2, 2006

Module 16: (min,max) Structural Constraint

1. Definition of the (min,max) notation for structural constraint.

2. Interpreting the (min,max) notation into participation and cardinality constraints.

Nov 2, 2006

Module 17: Bachman Notation

1. Entity sets – no more ovals…attributes listed inside the box (or use pop-up window in a computerized tool).

2. No more diamonds; a line connecting two boxes indicate relationship between two entity sets.

3. Adornment for structural constraints.

4. Notes on associative and attributive entities.

Bachman’s Notation

Employee Officeis assigned to

Every employee is assigned to exactly one office and every office is assigned one employee.

One-to-One relationship with total participation at both ends.

Bachman’s Notation

Cargo Aircraft

Distribution Center

serves

Every cargo aircraft serves one or more distribution centers and every center is served exactly one aircraft.

One-to-Many relationship with total participation at both ends.

Bachman’s Notation

Systems Analyst

Projectis in charge of

An analyst may be in charge of many projects (or may not be in charge of any) and every project has exactly one systems analyst in charge.

One-to-Many relationship with total participation at one end (Project) and partial at the other (Analyst).

Bachman’s Notation

Machine Scheduled Maintenance

is undergoing

A machine may or may not be undergoing scheduled maintenance and every scheduled maintenance always refers to exactly one machine.

One-to-One relationship with total participation at one end (Scheduled Maintenance) and partial at the other (Machine).

Bachman’s Notation

Salesperson Customeris assigned to call on

Every salesperson is assigned to call on one or more customers, and every customer has one or more salespersons assigned to call.

Many-to-Many relationship with total participation at both ends.

Bachman’s Notation

Home Office

Employeeis permitted to

Every home office is permitted to one or more employees, and an employee may or may not be permitted to a home office.

One-to-Many relationship with total participation at one end (Home Office) and partial at the other end (Employee).

Bachman’s NotationPartner participation is optional,

with at most one unit per partner: one-to-?

… (0,1).

Partner participation is mandatory,

with at most one unit per partner: one-to-?

… (1,1).

Partner participation is mandatory,

with possibly many units per partner: many-to-?

… (1,*).

Partner participation is optional,

with possibly many units per partner: many-to-?

… (0,*).

Nov 2, 2006

Module 18: ER Diagram in UML

1. Basic UML: classes and objects.

2. Public, private, and protected attributes.

3. Connection and multiplicities.

4. Broader software construction aspects of UML.

Nov 2, 2006

19 Modules to teach ER modeling

Small modules: complete and compact Specific learning objectives in each module Motivate self-study: perceiving progress… Minimize need for face-to-face contact hours Sequence: each builds on previous ones Exercise for each module re-enforces the

learning objectives thru practice. Suitable to delivery on-line.

Nov 2, 2006

Further Work …

Compare student performance and attitude to evaluate the effectiveness of the plan.

The modules may constitute a stand-alone tutorial on ER modeling.

Try the experimental use of Intelligent Tutoring System.

Gather sufficient exercises and tests to deliver the teaching on-line, for self-paced studying.

Recommended