Top Banner
Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University of Connecticut 191 Auditorium Road, Box U-155 Storrs, CT 06269-3155 [email protected] http://www.engr.uconn.edu/~steve (860) 486 - 4818 A large portion of these slides have been adapted from the AWL web site for the textbook. The remainder of these slides are being used with the permission of Dr. Ling Lui, Associate Professor, College of Computing, Georgia Tech.
112

Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Dec 29, 2015

Download

Documents

Noah 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: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-1

CSE 4701

Chapters 7 & 8 6e - 3 & 4 5e: The ER Model

Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department

The University of Connecticut191 Auditorium Road, Box U-155

Storrs, CT [email protected]

http://www.engr.uconn.edu/~steve(860) 486 - 4818

A large portion of these slides have been adapted from the AWL web site for the textbook.

The remainder of these slides are being used with the permission of Dr. Ling Lui, Associate Professor, College of Computing, Georgia Tech.

Page 2: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-2

CSE 4701

Information System Design

Page 3: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-3

CSE 4701

Data vs. Information

Page 4: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-4

CSE 4701

The ER Model and its extensions ER Diagrams- Notation Example Database Application (COMPANY) ER Model Concepts

Entities and Attributes Entity Types, Value Sets, and Key Attributes Relationships and Relationship Types Weak Entity Types Roles and Attributes in Relationship Types

Relationships of Higher Degree Extended Entity-Relationship (EER) Model Notation is based on :

R. Elmasri and S.B. Navathe, “ Fundamentals of Database Systems,” Ed. 6., Addison Wesley, 2000, Chapters 7 & 8.

Page 5: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-5

CSE 4701

Summary of ER-Diagram NotationMeaning

ENTITY TYPE

WEAK ENTITY TYPE

RELATIONSHIP TYPE

IDENTIFYING RELATIONSHIP TYPE

ATTRIBUTE

KEY ATTRIBUTE

MULTIVALUED ATTRIBUTE

COMPOSITE ATTRIBUTE

DERIVED ATTRIBUTE

TOTAL PARTICIPATION OF E2 IN R

CARDINALITY RATIO 1:N FOR E1:E2 IN R

STRUCTURAL CONSTRAINT (min, max) ON PARTICIPATION OF E IN R

Symbol

E1 R E2

E1 RN E2

R(min,max)

E

N

Page 6: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-6

CSE 4701

Example COMPANY Database Requirements of the Company (Oversimplified for

Illustrative Purposes) Company is Organized into Departments

Each Department has a Name, Number and an Employee Who Manages the Department

We Track of the Start Date of the Department Manager Each Department Controls a Number of Projects

Each Project has a Name, Number and is Located at a Single Location

Page 7: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-7

CSE 4701

Example COMPANY Database (Cont.) Store Each Employee’s Social Security Number,

Address, Salary, Sex, and Birthdate Each Employee Works for One Department but May

Work on Several Projects We Track of the Number of Hours Per Week that an

Employee Currently Works on Each Project We Track of the Direct Supervisor of Each Employee

Each Employee May have a Number of Dependents For Each Dependent, We Track of their Name, Sex,

Birthdate, and Relationship to Employee

Page 8: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-8

CSE 4701

ER Diagram for the Company Database

Page 9: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-9

CSE 4701

ER Model Concepts: Entities and Attributes Entities - Specific Objects or Things in the Mini-world

that are Represented in the Database EMPLOYEE John Smith Research DEPARTMENT Productx PROJECT

Attributes are Properties Used to Describe an Entitye.g., an EMPLOYEE Entity may have a Name, SSN, Address, Sex, Birthdate

A Specific Entity (Instance) has a Value for Each of its Attributes Specific Employee Entity May Have Name=‘John

Smith’, SSN=‘123456789’, Address=‘731 Fondren, Houston, TX’, Sex=‘m’, Birthdate=‘09-jan-55’

Page 10: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-10

CSE 4701

Three Types of Attributes Simple: Single Atomic Value for the Attribute

SSN or Sex or State or Salary or ... Composite: Attribute Composed of Many Components

Address (Apt#, House#, Street, City, State, Zipcode, Country) or Name(Fname, MI, Lname)

Composition May form a Hierarchy where Some Components are Themselves Composite

Multi-Valued: Entity may have Multiple Values for That Attribute - Like an Set Type CAR {Color} or STUDENT {Previousdegrees}

Composite and Multi-valued Attributes may be Nested Arbitrarily to any Number of Levels (Rare) Previousdegrees of a STUDENT is a Composite

Multi-valued Attribute Denoted by {Previousdegrees(college, Year, Degree, Field)}

Page 11: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-11

CSE 4701

Entities with Attribute Values

Page 12: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-12

CSE 4701

Entity Types and Key Attributes Entities with the Same Basic Attributes Are Grouped

or Typed into an Entity Type EMPLOYEE Entity Type or PROJECT Type

Attribute of Entity Type for which Each Entity Must Have a Unique Value is Called a Key Attribute SSN of EMPLOYEE, ISBN of BOOK

A Key Attribute may be Composite VIN is a Key of the CAR Entity Type

An Entity Type may have More than One Key CAR Entity Type May Have Two Keys:

VIN Vehicletagnumber (Number, State) aka License Plate

Page 13: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-13

CSE 4701

Entity Type a Class with no Methods Entity Represents the

Data itself to be Modeled Set of All Associated Instances

class Employee { private String Name, SSN, Address; private Date BirthDate; private double Salary; private integer DeptNum; };

Page 14: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-14

CSE 4701

car1

((ABC 123, TEXAS), TK629, Ford Mustang, convertible, 1989, (red, black))car2

((ABC 123, NEW YORK), WP9872, Nissan Sentra, 2-door, 1992, (blue))car3

((VSY 720, TEXAS), TD729, Chrysler LeBaron, 4-door, 1993, (white, blue))

.

.

.

CARRegistration(RegistrationNumber, State), V_ID, Make, Model, Year, (Color)

Entity Type CAR with Attributes

…. with Multiple Instances …

Page 15: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-15

CSE 4701

Two Other Entity Types

Page 16: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-16

CSE 4701

Relationships and Relationship Types A Relationship Relates Two or More Distinct Entities

With a Specific Meaning EMPLOYEE John Smith Works on the Productx

PROJECT EMPLOYEE Franklin Wong Manages the

Research DEPARTMENT Relationship - Instance Level

Relationships of the Same Type are Grouped or Typed Into a Relationship Type WORKS_ON Relationship Type in Which

Employees and Projects Participate MANAGES Relationship Type in Which

Employees and Departments Participate Analogous to Reference or List in Programming

Page 17: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-17

CSE 4701

The WORKS_ON Relationship

Page 18: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-18

CSE 4701

What Does the Relationship Represent? What is Equivalent Concept in a Relational Table?

Employee(EmpNo, EmpName, Title, etc.) Project(ProjNo, ProjName, etc.)

What Does Works_On Represent? Realization of a Table That Links Employee and

Project Has Attributes Duration & Responsibility

Works_On(EmpNo, ProjNo, Duration, Resp)

Page 19: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-19

CSE 4701

Relationships and Relationship Types Degree of a Relationship Type is the Number of

Participating Entity Types Both MANAGES and WORKS_ON are Binary

Relationships What is a possible Ternary Relationship?

More Than One Relationship Type Can Exist With the Same Participating Entity Types EMPOYEE MANAGES DEPARTMENT and

EMPOYEE WORKS_FOR DEPARTMENT Two Distinct Relationships Between EMPLOYEE

and DEPARTMENT Entity Types Relationships are Directional

SUPPLIES: SUPPLIER to PARTS SUPPLIERS: PARTS to SUPPLIER

Page 20: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-20

CSE 4701

E-R Diagrams

EMPLOYEE PROJECT

Responsibility

Duration

Budget

ProjectName

Project NoEmployee No EmployeeName

SalaryTitle

WORKS ON

Address

CityApt. #

Street #

NoEmp

Location

Page 21: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-21

CSE 4701

Weak Entity Types Entity that Does Not have a Key Attribute Weak Entity Must Participate in an Identifying

Relationship Type with an Owner or Identifying Entity Type

Entities are Identified by the Combination of: A Partial Key of the Weak Entity Type Particular Entity they Are Related to in the

Identifying Entity Type Example:

A DEPENDENT Entity is Identified by Dependent’s First Name and Birthdate, and the EMPLOYEE That the Dependent is Related to

DEPENDENT is a Weak Entity Type With EMPLOYEE as its Identifying Entity Type Via the Identifying Relationship Type DEPENDENT_OF

Page 22: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-22

CSE 4701

ER Model and Data Abstraction Abstraction Classification

Aggregation

Identification Generalization

ER Model Concept Entity Type - a Grouping of Member Entities Relationship Type - a Grouping of Member

Relationships Relationship Type is an Aggregation of (Over) Its

Participating Entity Types Weak Entity Type and Attribute Key EER Diagram … TBD

Page 23: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-23

CSE 4701

Constraints on Aggregation Cardinality Constraints on Relationship Types

AKA Ratio Constraints Maximum Cardinality

One-to-One One-to-Many Many-to-Many

Minimum Cardinality (AKA Participation or Existence Dependency Constraints) Zero (Optional Participation, Not Existence-Dependent) One or More (Mandatory, Existence-Dependent)

Page 24: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-24

CSE 4701

e1

e2

e3

e4

e5

e6

e7

EMPLOYEE

r1

r2

r3

r4

r5

r6

r7

WORKS_FOR

d1

d2

d3

DEPARTMENT

One-to-many(1:N) or Many-to-one (N:1)One Dept Contains Many Employees (1:N)Many Employees Works for One Dept (N:1)

Page 25: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-25

CSE 4701

e1

e2

e3

e4

e5

e6

e7

r1

r2

r3

r4

r5

r6

r7

d1

d2

d3

r8

r9

MANY-TO-MANY(M:N)

Page 26: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-26

CSE 4701

One-to-One WORKS_ON Relationship

WORKS_ONRelationship

Instances

EMPLOYEE Set PROJECT Set

One Employee Works on One Project (1:1)

Page 27: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-27

CSE 4701

EMPLOYEE PROJECT

Responsibility

Duration

Budget

ProjectName

Project NoEmployee No EmployeeName

SalaryTitle

WORKS ON1 1

One-to-One Relationship Each Instance of One Entity Class E1 Can Be

Associated with Exactly One Instance of Another Entity Class E2 and Vice Versa.

Example: Each Employee Can Work in Exactly One Project

and Each Project Employs Exactly One Employee

Page 28: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-28

CSE 4701

One-to-Many WORKS_ON Relationship

Page 29: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-29

CSE 4701

EMPLOYEE PROJECT

Responsibility

Duration

Budget

ProjectName

Project NoEmployee No EmployeeName

SalaryTitle

WORKS ON1N

Many-to-One Relationship Each Instance of One Entity Class E1 can be

Associated with Zero or More Instances of Another Entity Class E2, but Each Instance of E2 can be Associated With at Most 1 Instance of E1

Example : Each Employee Can Work in Exactly One Project

Each Project Can Employ Many Engineers

Page 30: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-30

CSE 4701

Many-to-Many WORKS_ON Relationship

Page 31: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-31

CSE 4701

EMPLOYEE PROJECT

Responsibility

Duration

Budget

ProjectName

Project NoEmployee No EmployeeName

SalaryTitle

WORKS ONN M

Many-to-Many Relationship Each Instance of One Entity Class Can Be Associated

with Many Instances of Another Entity Class, and vice versa

Example: Each Employee Can Work in Many Projects

Each Project Can Employ Many Employees

Page 32: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-32

CSE 4701

Structural Constraints Structural Constraints on a Relationship are One Way

to Express the Semantics of a Relationship Cardinality Ratio (of a Binary Relationship):

1:1, 1:N, N:1, or M:N Shown by Placing Apropos Number on the Link

Participation Constraint (on Each Entity Type): Total (Called Existence Dependency) or Partial Total Shown By Double Lining The Link

NOTE: Easy to Specify for Binary Relationship Types Do Not Be Misled by Obscure Notations to

Specify Above Constraints for Higher Order Relationships

Page 33: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-33

CSE 4701

Alternative (min, max) Notation Alternative (Min, Max) Notation for Relationship

Structural Constraints Introduces Limits Specified on Each Participation of an Entity Type E in

a Relationship Type R Specifies That Each Entity E in Participates in at Least

Min and at Most Max Relationship Instances in R Default (no Constraint): Min = 0, Max = n Must Have Min max, Min 0, Max 1

Derived From the Knowledge of Mini-World Constraints

A Full Time Student for the Registered Relationship Must Registered for at Least 3 courses and at most 6

Page 34: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-34

CSE 4701

Examples: Alternative (min, max) Notation A Department has Exactly One Manager and an

Employee Can Manage at most One Department. Specify (0, 1) for Participation of EMPLOYEE in

MANAGES – Not every employee manager (0) Specify (1, 1) for Participation of DEPARTMENT

in MANAGES – Each dept needs a manger An Employee can Work for Exactly One Department

but a Dept. can have any Number of Employees Specify (1, 1) for Participation of EMPLOYEE in

WORKS_FOR Specify (0, n) for Participation of DEPARTMENT

in WORKS_FOR

Page 35: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-35

CSE 4701

Examples: Alternative (min, max) Notation

What does it mean to put m:n:p on the three arms of the relationship? It is essentially meaningless. The (min,max) notation “looking away” from the entity is the best to use.

(1,1)(0,1)

(1,N)(1,1)

Page 36: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-36

CSE 4701

Relationships of Higher Degree Relationship Types of Degree 2 Are Called Binary Relationship Types of Degree 3 Are Called Ternary

There is a Concrete Relationship Instance that Involves all Three Entity Types

These are Not Separate Relationships! Relationship Types of Degree N Are Called N-ary

Again - Concrete n-Participation Relationship In General, an N-ary Relationship is Not Equivalent to

N Binary Relationships Rather - it is more Analogous to the Grouping of

N-Binary Relationships into a N-ary Relationship

Page 37: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-37

CSE 4701

Ternary Relationships

How is this Interpreted?

Are three Relationships

Easier to Understand?

Page 38: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-38

CSE 4701

Ternary Relationships – in SQL Tables

Supply(SName, PartNo, ProjName, Qty)

Supplies(SName, ProjName)Can_Supply(SName, PartNo)Uses(PartNo, ProjName)

Page 39: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-39

CSE 4701

Ternary Relationships Alternatively, Could Use Weak Entity (Supply) and

Three Identifying Relationships (SS, SPJ, SP) Generate one Relational Table Supply that Links

Supplier, Project, and Part by SS, SPJ, SP, Respect.

Page 40: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-40

CSE 4701

Ternary vs. Binary Relationships

Page 41: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-41

CSE 4701

Constraints on Higher Order Relationships

What does it mean to put m:n:p on the three arms of the relationship ?

How do you set up the instance level diagram between actual suppliers, projects, and parts?

mn

p

Page 42: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-42

CSE 4701

Higher Order (min,max) Examples

A Teacher can offer min 1 and max 2 OfferingsA Course may have 1 to 3 OfferingsA Student may enroll in from 1 to 5 Offerings

(1,5)

(1,3)(1,2)

What Does Each Mean?

Page 43: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-43

CSE 4701

s1

s2

SUPPLIER

p1

p2

p3

PART

r1

r2

r3

r4

r5

r6

r7

SUPPLY

j1

j2

j3

PROJECT

Ternary Relationships - Instances

Page 44: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-44

CSE 4701

Modified Earlier Example

Page 45: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-45

CSE 4701

Another ER Diagram - Bank Example

Page 46: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-46

CSE 4701

In Class Exercise Patients (name, address, SSN, etc.), Physicians (name,

specialty, DEA#, etc.) , and Drug Companies (name, phone number, web site)

Drug (name, price, status (generic, brand), drug companies that sell the drug, etc.)

Each patient has a primary physician, a collection of physicians that can prescribe them drugs

Physician’s prescribe, can prescribe multiple drugs per patient to multiple patients

Physicians can prescribe the same or different drugs to the same or different patient

Prescription has a date, refills, DEA#, dosage (assume milligrams), pattern (1perday, 2perday, etc.), and fill requirement (brand or generic)

ABC Pharmacy has Contacts with many Companies with Start and End dates, QTY, etc.

What would the ER Diagram Look Like?

Page 47: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-47

CSE 4701

Starting the Design What are the Entities?

What are the Relationships?

Patient, Physician, Drug Company, Drug

Patient has one Primary PhysicianEach Physician has Multiple Patients

Drug Company has Purchasing Contract on DrugsDrug Company Sells Multiple DrugsDrugs Sold by Multiple Companies

Physician Prescribes Multiple Drugs per PatientPatient has Multiple Drug PrescriptionsPhysician Prescribes to Multiple PatientsPatient gets Prescriptions from Multiple Physicians

Page 48: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-48

CSE 4701

One Solution – Where is ABC?

Phone#

Patient

Drug

Physician

name

address email

SSN

status

price

name

expiration

name

email

address

specialtyPrimary

N 1

DEA#

Prescribes

refills N

N

dosage

dateFill

requirementpattern

Sold By

Purchasing Contract

start_date end_date

Page 49: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-49

CSE 4701

ER Data Modeling Tools Many Popular Existing Tools Advantages:

Documentation of Application Requirements User Interface - Mostly Graphics Editor Support

Disadvantages: Poor Diagramming

To Avoid Layout Algorithms and Aesthetics of Diagrams, They Prefer Boxes and Lines and Typically Only Represent (Primary-foreign Key) Relationships Among Resulting Tables

Lack of Built-in Methodology Support Poor Tradeoff Analysis/User-driven Design Preferences Poor Design Verification/Suggestions for Improvement

Page 50: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-50

CSE 4701

Data modeling, design and reengineering Visual Basic and Visual C++

Visio EnterpriseVisio

Data modeling, business logic modelingEnterprise Application SuiteSybase

Conceptual modeling up to code maintenanceXcaseResolution Ltd.

Mapping from O-O to relational modelRW MetroRogue Ware

Modeling in UML and generation in C++ and JAVATogether has support for limited ER Design

Rational RoseTogether Control Center

RationalTogether/Borland

Mapping from O-O to relational modelPwertierPersistence Inc.

Data, process, and business component modelingPlatinum Enterprice Modeling Suite: Erwin, BPWin, Paradigm Plus

Platinum Technology

Data modeling, object modeling, process modeling, structured analysis/design

System Architect 2001Popkin Software

Database modeling, application developmentDeveloper 2000 and Designer 2000

Oracle

Database administration and space and security management

DB Artisan

Database Modeling in ER and IDEF1XER StudioEmbarcadero Technologies

FUNCTIONALITYTOOLCOMPANY

Tools Circa 2007 ER Modeling Tools

OutDated

Page 51: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-51

CSE 4701

Current Tools Quest Software's Toad Data Modeler for SQL

Server 3.5, Xpert Edition Altova's DatabaseSpy 2011, Enterprise Edition Datanamic Solutions' DeZign for Databases 6.2,

Expert Edition Embarcadero Technologies' ER/Studio Enterprise

8.5 CA's ERwin Data Modeler (DM) 7.3 Sybase's PowerDesigner Studio Enterprise 15.2 See also:

https://en.wikipedia.org/wiki/Comparison_of_data_modeling_tools http://www.databaseanswers.org/modelling_tools.htm

Page 52: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-52

CSE 4701

ER Design Topics Clear Distinction of the Usage of Entity and Attribute,

As Well As Entity and Relationship Clear Understanding of Complications in ER

Modeling Recursive Relationship Multiple Relationships Between Two Entity Types Participation Constraints (Existence Constraints) Strong and Weak Entities Relationships Among More than two Entity Types Connection Traps Simplification Techniques

Page 53: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-53

CSE 4701

Interactions of Entity/Relationships Types In a Recursive Relationship two Entities of the Same

Entity Type Are Related SUPERVISION Relationship Type Relates One

EMPLOYEE (in the Role of Supervisee) to Another EMPLOYEE (in the Role of Supervisor)

Similarly, the Same Entity Type May Play Different Roles in Different Relationships Employee Plays the Role

A Relationship Type Can Have Attributes HoursPerWeek of WORKS_ON Value for Relationship Instance Describes # of

hrs/week an EMPLOYEE Works on a PROJECT

Page 54: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-54

CSE 4701

Recursive Relationships

EMPLOYEE

MANAGES

1 N

Manager Subordinate

PART

CONTAIN

M N

Made-up of Consists of

Page 55: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-55

CSE 4701

Understanding Multiple Relationships

EMPLOYEE PROJECT

ResponsibilityDuration

Budget

ProjectName

Project NoEmployee No EmployeeName

SalaryTitle

WORKS ON

N M

MANAGES

1 1

Page 56: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-56

CSE 4701

Strong and Weak Entity Types Strong Entities:

Instances of the Entity Class Can Exist on their Own, Without Participating in any Relationship

Non-obligatory Membership Weak Entities:

Each Instance of the Entity Class Has to Participate in a Relationship in Order to Exist

Keys Are Imported From Dependent Entity

Also Called Obligatory Membership

Special Type of Total Participation

What Does Diagram Represent?

Course

number-of- sessions

instructorsession#

1

n

C-S

Session

Page 57: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-57

CSE 4701

Higher Order Relationships

SUPPLIERPROJECT

DateAmount

Budget

ProjectName

Project NoSupplier No Supplier

Name

LocationCredit SUPPLY

NM

PART

LPart No

PartName

QTY

WGT

Three way relationships

Page 58: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-58

CSE 4701

Connection Traps A N-ary Relationship cannot be Replaced by

a Number of Binary Relationships (Loss of Information)

(Supplier,Project,Part)< > (Project,Supplier)+(Supplier,Part)+(Project,Part)

So, (a) < > (b)! There are no Easy Solutions to this

Problem! Equivalent Relational Tables Different

(previous)

Page 59: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-59

CSE 4701

Connection Traps - Example 2 Example: Each Division Has Multiple Depts. and Many

Employees , Each Employee Works for One Dept. in a Div., and Each Dept. is Within a Div. and Has Many Employees

Be Careful in Defining and Interpreting Relationships For Example, Consider the Following Diagram

Can We Find, for Any Given Emp., Which Dept. He is in? Conversely, Can We Find, for a Given Dept., Which Emps.

are in that Dept.?

DIVISION

DEPARTMENT EMPLOYEE

1

N

1

N

INCLUDESDEPT

INCLUDESEMP

Page 60: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-60

CSE 4701

Example 2 - One Solution Change the Relationship Definition Division to Dept. and Dept. to Employee Replaces

Division to Dept. and Division to Employee

DIVISION

DEPARTMENT

EMPLOYEE

1

N 1

N

INCLUDESDEPT

INCLUDESEMP

Page 61: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-61

CSE 4701

Many-to-Many Simplification Technique Cannot do by Simple Creation of two 1:N

Relationships Between the Two Entity Classes N:M Relationship Does Not Indicate a Dependence

Between Instances of the Two Entity Classes 1:N Relationship Forces a Dependency

Consider N:M Between EMPLOYEE and PROJECTN M

EMPLOYEE PROJECTWORKS ON

EMPLOYEE PROJECT

WORKS ON N

M EMPLOYS

1

1

WRONG

Page 62: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-62

CSE 4701

Many-to-Many Simplification Technique Treat the Relationship as an Entity Class Define Suitable Relationships Among Three Entities This Simplification is not Necessary for Mapping into

the Relational Model, but is Important for Mapping into Other Models (Relational/Implementation)

EMPLOYEE PROJECTWORKS ONN M

EMPLOYEE PROJECT

EMP--EMP1

M

EMP--PROJ

EMPLOYMENT M

1

Page 63: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-63

CSE 4701

What are Problems with ER Notation? Historically, ER Model 1st Proposed in 1976

P. Chen, ''The Entity-Relationship Model - Toward a Unified View of Data,'' ACM Trans. on Database Systems, Vol. 1, No. 1, March 1976.

However, ER Model in this Original Form Did Not Support the Generalization Abstraction (Inheritance)

In Databases, Inheritance 1st Proposed in 1977 J. Smith and D. Smith, ''Database Abstractions:

Aggregation and Generalization,'' ACM Trans. on Database Systems, Vol. 2, No. 2, June 1977.

Thus, Extended ER Evolved through 1980s with the Focus on “Semantic Data Models”

M. Hammer and D. McLeod, ''Database Descriptions with SDM: A Semantic Data Model,'' ACM Trans. on Database Systems, Vol. 6, No. 3, Sept. 1981.

Page 64: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-64

CSE 4701

Enhanced ER Model Object-Oriented Extensions to E-R Model EER Concepts

Specialization Attribute Inheritance Generalization Subclasses Superclasses Constraints on Specialization and Generalization Categorization

Page 65: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-65

CSE 4701

Specialization/Attribute Inheritance An Entity Type E1 is a Specialization of

another Entity Type E2 if E1 has the Same Properties of E2 and Perhaps Even More.

E1 IS-A E2

MANAGER

EMPLOYEE

EMPLOYEE

Employee No EmployeeName

Salary

Title Address

MANAGER

Employee No EmployeeName

Salary

Title Address

Expense Act. Condo

Page 66: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-66

CSE 4701

Generalization Abstracting the Common Properties of Two

or More Entities to Produce a “Higher-level” Entity

ENGINEER SECRETARY SALESPERSON

Employee NoEmployee Name

SalaryTitle

Address

Employee NoEmployee Name

SalaryTitle

Address

Employee NoEmployee Name

SalaryTitle

Address

ProjectOffice Office

SpecialtyCarRegion

EMPLOYEE Employee NoEmployee Name

SalaryTitle

Address

Page 67: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-67

CSE 4701

Generalization

ENGINEER SECRETARY SALESPERSON

EMPLOYEE

Employee No EmployeeName

Salary

Title Address

Project Office Specialty Office CarRegion

d

What Does “d” Mean?

Page 68: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-68

CSE 4701

Constraints

disjoint, total

disjoint, partiald

d

o

o

overlapping, total

overlapping, partial

Part

Manufactured_Part

Purchased_Part

o

PartNo Description

SupplierName ListPrice

BatchNo

M_date

DrawingNo

Page 69: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-69

CSE 4701

Total and Partial Disjoint

EMPLOYEE

Employee No EmployeeName

Salary

Title Address

SECRETARYENGINEER

Project Office Specialty Office

SALESPERSON

CarRegion

dd

HOURLY_EMP

SALARIED_EMP

Hourly Rate

Salary

How is Diagram Interpreted?

Page 70: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-70

CSE 4701

Other Disjoint

How is Diagram Interpreted?

Page 71: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-71

CSE 4701

Total Overlapping

PART

Part No PartName

QTY

WGT

o

MANUFACTURED_PART PURCHASED_PART

Batch No Drawing No Price

What Does Overlapping Mean?

Page 72: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-72

CSE 4701

Other Overlapping

Page 73: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-73

CSE 4701

Categories A Category is a Subclass

of a Union of Two or More Entity Types.

The Concept of Category Superclass

Relationship with Two or More Superclasses

A Category Can Be Total or Partial

Owner a Person, Bank, or Company

Can Own Car or Truck

PERSON BANK COMPANY

OWNER

u

REG_VEHICLE

CAR TRUCK

u

OWNS

N

M

OWNER and REG_VEHICLE

are both categories

Page 74: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-74

CSE 4701

Unions in EER

Page 75: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-75

CSE 4701

A Combination Example

Page 76: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-76

CSE 4701

Enhanced ER Constructs and Notation

Page 77: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-77

CSE 4701

Page 78: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-78

CSE 4701

How can this be restructured?

Page 79: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-79

CSE 4701

Page 80: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-80

CSE 4701

Page 81: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-81

CSE 4701

In Class Exercise …Modify Banking Schema ACCOUNTS (SAVINGS, CHECKING, IRA) LOANS (CAR, HOME, CREDIT_LINE, PERSONAL) ACCOUNT’s TRANSACTIONS (deposits, withdrawals, checks, interest) LOAN’s PAYMENTS

both include the amount, date, and time. How Would the ER be Modified to an EER?

Page 82: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-82

CSE 4701

How are Different Accounts Added?

Acct no Balance

IRA

Interest Type Beneficiary

Page 83: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-83

CSE 4701

How are Different Loans Added?

Loan no Amount

Interest

Page 84: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-84

CSE 4701

How do we keep Track of ACCT Trans?

deposits, withdrawals, checks, interest

Acct no Balance

IRA

Interest Type Beneficiary

Page 85: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-85

CSE 4701

How do we keep Track of LOAN Payments?

deposits, withdrawals, checks, interest

Loan no Amount

Interest

Page 86: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-86

CSE 4701

UML for System Modeling UML is a Language for Specifying, Visualizing,

Constructing, and Documenting Software Artifacts What Does a Modeling Language Provide?

Model Elements: Concepts and Semantics Notation: Visual Rendering of Model Elements Guidelines: Hints and Suggestions for Using

Elements in Notation References and Resources

Web: www.rational.com/uml/documentation.html “The Unified Modeling Language Reference

Manual”, Addison-Wesley, 1999. “UML Toolkit”, Eriksson and Penker, John Wiley

& Sons, Inc, New York, 1998.

Page 87: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-87

CSE 4701

UML Modeling Constructs/Diagrams A Diagram Is a View Into a Model

Presented From the Aspect of a Particular Stakeholder

Provides a Partial Representation of the System Is Semantically Consistent With Other Views

In the UML, There Are Nine Standard Diagrams Static Views: Use Case, Class, Object,

Component, Deployment Dynamic Views: Sequence, Collaboration,

Statechart, Activity Red are most related to ER Design

Page 88: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-88

CSE 4701

Classification by Capability/Timeline Use-Case Diagrams Class and Object Diagrams Behavior Diagrams

Statechart Diagrams Activity Diagrams

Interaction Diagrams Sequence Diagram Collaboration Diagram

Implementation Diagrams Component Diagram Deployment Diagram

Page 89: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-89

CSE 4701

Relationship Between Models and Diagrams

Use CaseDiagramsUse Case

DiagramsUse CaseDiagrams

ScenarioDiagramsScenario

DiagramsCollaborationDiagrams

StateDiagramsState

DiagramsComponentDiagrams

ComponentDiagramsComponent

DiagramsDeploymentDiagrams

StateDiagramsState

DiagramsObjectDiagrams

ScenarioDiagramsScenario

DiagramsStatechartDiagrams

Use CaseDiagramsUse Case

DiagramsSequenceDiagrams

StateDiagramsState

DiagramsClassDiagrams

ActivityDiagrams

Models

Page 90: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-90

CSE 4701

Use-Case Diagrams One of the Key Diagrams Used in Conjunction with DB Design Interaction of Users with System Components Actors – Can Transition to Users/Privileges Against DB

External Entity that Interacts with Software Promote Simulation of Events Can be People, Classes, Software Tools, etc.

Use-Case Diagram Graph of Actors and Set of Use Cases Enclosed by System

(High-Level) or Class Boundary Focus on What Actions, Methods, Functions, etc. are

Utilized by Which Actors Black Box View of System Components Derived via User Interviews

Page 91: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-91

CSE 4701

Actors Generalization from Child to Parent Association to a Use Case

Use-Cases Generalization

Child Use Case X to a Parent UC Y means that X inherits Behaviors/Meanings of Y

<<Include>> Base UC C to Included UC D means that C

contains the Behaviors defined in D <<Extend>>

From Extending UC E to Base UC F means that F Augmented with Behaviors of E

Include/Extend – Relationships Among Use Cases

Use-Case Relationships

Page 92: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-92

CSE 4701

Supermarket Example

HTSS

Scan Items

Ring Order

Buy Items CustomerCashier

Catalog

Check Status

Place Order

Fill Order

Estb. Credit

Customer

Sales Person

Supervisor

HTSS: System View

Catalog: Class View

Page 93: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-93

CSE 4701

Supermarket Example

Page 94: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-94

CSE 4701

Use Case Scenario Write Rx Physician Decides to

Prescribe Medication for Patient

Physician Specifies Drug Info: Medication Name, Dosage Amount, Number Doses & Refills

Computer Cross-Checks for Conflict Between Medication and Current Medications/Medical History

Prescription Forwarded Electronically to Pharmacy or Else Printed for Patient

+

Page 95: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-95

CSE 4701

Health Care Example

Page 96: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-96

CSE 4701

Use-Case Diagrams

Page 97: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-97

CSE 4701

Another Important Diagram to DB Design Need to Synchronize ER Entities and App Classes

Utilized for Static Structure of Conceptual Model Class Diagram Describes

Types of Objects in Application Static Relationships Among Objects Temporal Information Not Supported

Class Diagrams Contain Classes: Objects, Attributes, and Operations Packages: Groupings of Classes Subsystems: Grouping of Classes/Packages

Main Concepts: Class, Association, Generalization, Dependency, Realization, Interface

Class Diagram

Page 98: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-98

CSE 4701

A Class is a Description of Set of Objects that Share the Same Attributes, Operations, Methods, Relationships, and Semantics

Classes are Graphically Represented as Boxes with Compartments for Class Name, Private Attributes, and Public

Operations Properties, Responsibilities, Rules, Modification

History, etc. Designer Develops Classes as Sets of Compartments

that Grow Over Time to Incrementally Add Functionality and Features

Class Diagrams

Page 99: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-99

CSE 4701

Relationships: Association -- between two classes if an instance of one

class must know about the other in order to perform its work

Aggregation -- an association in which one class belongs to a collection

Generalization -- an inheritance link indicating one class is a superclass of the other

Multiplicities 0..1 zero or one instance n . . m indicates n to m instances 0..*  or  * no limit on the number of instances (including

none) 1 exactly one instance 1..* at least one instance

Again – Similarity in Relationships in Classes and Entities

Relationships and Multiplicity

Page 100: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-100

CSE 4701

Example Class Diagrams

Window {abstract, author=Joe, status=tested}

+size: Area = (100,100)#visibility: Boolean = invisible

+default-size: Rectangle#max-size: Rectangle

-xptr: XWindow

+display()+hide()

+create()-attachXWindow(xsin:Xwindow)

What do +, #, - Represent?

+ Public # Protected - Private

Window

+size: Area = (100,100)+default-size: Rectangle

+display()+hide()

+create()

ProvidingSpecialized Views

Page 101: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-101

CSE 4701

Generalization and Associations

Item

NonPItem PerishItem

DeliItem ProduceItemDiaryItem

Customer

GroceryOrder

1

*

DeliOrder

1

*

contains

Page 102: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-102

CSE 4701

Supermarket Example in Detail

Page 103: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-103

CSE 4701

Class Diagram in Health Care

PharmacyDB

AddRxRecFillRx

RefillRxDeleteRxRec

MedicationMedicationName

ConflictInfoCheckForConflict

UpdateConflictInfo

1

RxRxNum

PhysicanNamePatientName

MedicationNameDosage

NumDosesNumRefillsRefillsLeftWriteRx

PatientRecPatientNamePatientSSNDateOfBirth

InsurerPolicyNum

etc...UpdateRec

etc...

MedicalHistoryMedicationHistoryKnownAllergiesImmunizationsPregnancyData

etc...

1n

n

n

1

Page 104: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-104

CSE 4701

Class Diagram

Page 105: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-105

CSE 4701

Class Diagram (part 2 - Under Item)

Page 106: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-106

CSE 4701

Object Diagram Captures Instances and Links

Page 107: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-107

CSE 4701

Component Diagram Captures the Physical Structure of the Implementation

Page 108: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-108

CSE 4701

Deployment Diagram Captures the Topology of a System’s Hardware

Page 109: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-109

CSE 4701

Sequence Diagram

Page 110: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-110

CSE 4701

Statechart Diagram Captures Dynamic Behavior (Event-Oriented)

Page 111: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-111

CSE 4701

Activity Diagram Captures Dynamic Behavior (Activity-Oriented)

Page 112: Chaps7&8-1 CSE 4701 Chapters 7 & 8 6e - 3 & 4 5e: The ER Model Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.

Chaps7&8-112

CSE 4701

Concluding Remarks Database Design is one Aspect of the Overall Software

Engineering Process Software Specification Software Architecture Database Requirements and Model UML Use-Cases Detailed Design (Classes, etc.)

The ER Model and EER Model are Excellent Conceptual Modeling Vehicles What is the Data? What are Data Dependencies? How will Data be Used?