Chapter 6
Developing Data Models for
Business Databases
Database Design, Application Development, and
Administration, 5th Edition
Copyright © 2011 by Michael V. Mannino All rights reserved.
Outline
 Guidelines for analyzing business
information needs
 Transformations for generating alternative
designs
 Finalizing an ERD
 Schema Conversion
Chapter 6: Developing Data Models for Business Databases
Slide 2
Characteristics of Business Data
Modeling Problems
 Poorly defined





Conflicting statements
Wide scope
Missing details
Many stakeholders
Requirements in many formats
 Add structure
 Eliminate irrelevant details
 Add missing details
 Narrow scope
Chapter 6: Developing Data Models for Business Databases
Slide 3
Goals of Narrative Problem
Analysis
 Consistency with narrative
 No contradictions of explicit narrative
statements
 Identify shortcomings
 Ambiguous statements
 Missing details
 Simplicity preference
 Choose simpler designs especially in initial
design
 Add refinements and additional details later
Chapter 6: Developing Data Models for Business Databases
Slide 4
Steps of Narrative Problem
Analysis
 Identify entity types and attributes
 Determine primary keys
 Add relationships
 Determine connections
 Determine relationship cardinalities
 Simplify relationships
Chapter 6: Developing Data Models for Business Databases
Slide 5
Determine Entity Types and
Attributes
 For entity types, find nouns that represent
groups of people, places, things, and
events
 For attributes, look for properties that
provide details about the entity types
 Simplicity principal: consider as an
attribute unless other details
Chapter 6: Developing Data Models for Business Databases
Slide 6
Determine Primary Keys
 Stable: never change after assigned
 Single purpose: no other purpose
 Good choices: automatically generated
values
 Compromise choice for industry practices
 Identify other unique attributes
Chapter 6: Developing Data Models for Business Databases
Slide 7
Government Identifiers
 Widely used for tax returns and
government benefits
 Avoid for primary keys
 Privacy concerns
 Prohibited by organization policies
 Sometimes violate single-purpose tenet
 May need to store as an attribute for
government compliance
Chapter 6: Developing Data Models for Business Databases
Slide 8
Entity Identification Example
Customer
CustNo
CustName
CustAddr
CustType
Meter
MeterNo
MtrAddr
MtrSize
MtrModel
Bill
BillNo
BillDate
BillStartDate
BillEndDate
BillDueDate
Reading
ReadNo
ReadTime
ReadLevel
EmpNo
Rate
RateNo
RateDesc
RateFixedAmt
RateThresh
RateVarAmt
Chapter 6: Developing Data Models for Business Databases
Slide 9
Identify Relationships
 Identify relationships connecting previously
identified entity types
 Relationship references involve associations
among nouns representing entity types
 Sentences that involve an entity type having
another entity type as a property
 Sentences that involve an entity type having a
collection of another entity type
Chapter 6: Developing Data Models for Business Databases
Slide 10
Relationship Identification
Example
Rate
RateNo
Customer
Assigned
CustNo
Meter
Uses
SentTo
ReadBy
Bill
BillNo
Chapter 6: Developing Data Models for Business Databases
MeterNo
Reading
Includes
ReadNo
Slide 11
Relationship Simplification
 Problem statement requires direct or
indirect connections
 Hub entity types to simplify
 Connect other entity types
 Sometimes associated with important
documents
 Reduce number of direct connections
Chapter 6: Developing Data Models for Business Databases
Slide 12
Diagram Refinements
 Construct initial ERD
 Revise many times
 Generate feasible alternatives and
evaluate according to requirements
 Gather additional requirements if needed
 Use transformations to suggest feasible
alternatives
Chapter 6: Developing Data Models for Business Databases
Slide 13
Attribute Expansion
Transformation
Reading
Reading
ReadNo
ReadTime
ReadLev el
ReadNo
ReadTime
ReadLev el
EmpNo
Perf orms
Em ployee
EmpNo
EmpName
EmpTitle
Chapter 6: Developing Data Models for Business Databases
Slide 14
Compound Attribute
Transformation
C u stom e r
Cust No
Cust Name
Cust Addr
Cust T ype
Chapter 6: Developing Data Models for Business Databases
C u stom e r
Cust No
Cust Name
Cust St reet
Cust Cit y
Cust St at e
Cust Post al
Cust T ype
Slide 15
Entity Type Expansion
Transformation
Rate Set
Rate
RateNo
RateDesc
RateFixedAmt
RateVarAmt
RateThresh
RateSetNo
RSApprDate
RSEf f Date
RSDesc
Contains
Rate
MinUsage
MaxUsage
FixedAmt
VarAmt
Chapter 6: Developing Data Models for Business Databases
Slide 16
Entity Type Expansion
Transformation II
b) Position expansion
Position
PosNo
PosName
PosMinSal
PosMaxSal
JobClass
JCNo
JCName
JCMinSal
JCMaxSal
Contains
Position
PosNo
PosStepNo
PosDesc
Chapter 6: Developing Data Models for Business Databases
Slide 17
Weak to Strong Entity
Transformation
RateSet
RateSet
RateSetNo
RSApprDate
RSEffDate
RSDesc
RateSetNo
RSApprDate
RSEffDate
RSDesc
Contains
Contains
Rate
Rate
MinUsage
MaxUsage
FixedAmt
VarAmt
RateNo
MinUsage
MaxUsage
FixedAmt
VarAmt
Chapter 6: Developing Data Models for Business Databases
Slide 18
Attribute History Transformation
Employee
EmpNo
EmpName
Employee
EmpNo
EmpName
EmpTitle
TitleChanges
TitleHistory
VersionNo
BegEffDate
EndEffDate
EmpTitle
Chapter 6: Developing Data Models for Business Databases
Slide 19
1-M Relationship History
Transformation
Customer
Customer
CustNo
...
CustNo
...
UsesAt
MeterUsage
VersionNo
BegEffDate
EndEffDate
Uses
Meter
Meter
MeterNo
...
MeterNo
...
Chapter 6: Developing Data Models for Business Databases
UsedBy
Slide 20
M-N Relationship History
Transformation (I)
Customer
Customer
CustNo
...
CustNo
...
LivesAt
Resides
VersionNo
BegEffDate
EndEffDate
ResidesAt
Residence
Residence
ResNo
...
ResNo
...
Chapter 6: Developing Data Models for Business Databases
Houses
Slide 21
M-N Relationship History
Transformation (II)
Customer
Customer
CustNo
...
CustNo
...
LivesAt
ResidesPeriod
VersionNo
BegEffDate
EndEffDate
ResidesAt
Residence
Residence
ResNo
...
ResNo
...
Chapter 6: Developing Data Models for Business Databases
Houses
Slide 22
Limited History Transformation
Employee
EmpNo
EmpName
EmpCurrTitle
EmpCurrTitleBegEffDate
EmpCurrTitleEndEffDate
EmpPrevTitle
EmpPrevTitleBegEffDate
EmpPrevTitleEndEffDate
Chapter 6: Developing Data Models for Business Databases
Slide 23
Generalization Hierarchy
Transformation I
Customer
CustNo
CustName
CustType
CustAddr
TaxPayerID
EnterpriseZone
Subsidized
DwellingType
Customer
CustNo
CustName
CustAddr
D,C
Commercial
TaxPayerID
EnterpriseZone
Chapter 6: Developing Data Models for Business Databases
Residential
Subsidized
DwellingType
Slide 24
Generalization Hierarchy
Transformation II
Residential
Customer
CustNo
CustName
CustAddr
Subsidized
DwellingType
CustNo
CustName
CustAddr
D,C
Commercial
CustNo
CustName
CustAddr
TaxPayerId
EnterpriseZone
Commercial
Residential
TaxPayerId
EnterpriseZone
Subsidized
DwellingType
Chapter 6: Developing Data Models for Business Databases
Slide 25
Summary of Transformations





Attribute expansion
Compound attribute split
Entity type expansion
Weak entity to strong entity
Add history: attributes, 1-M relationships,
and M-N relationships
 Generalization hierarchy addition
Chapter 6: Developing Data Models for Business Databases
Slide 26
Documenting an ERD
 Important for resolving questions and
communicating a design
 Identify inconsistency and incompleteness
in a specification
 Identify situations when more than one
feasible alternative exists
 Do not repeat the details of the ERD
 Incorporate documentation into the ERD
Chapter 6: Developing Data Models for Business Databases
Slide 27
Documentation with the ER
Assistant





Attribute comments
Entity type comments
Relationship comments
Design justifications
Diagram notes
Chapter 6: Developing Data Models for Business Databases
Slide 28
Common Design Errors
 Misplaced relationships: wrong entity types connected
 Incorrect cardinalities: typically using a 1-M relationship
instead of a M-N relationship
 Missing relationships: entity types should be connected
directly
 Overuse of specialized modeling constructs:




Generalization hierarchies,
Identification dependency,
Self-referencing relationships,
M-way associative entity types
 Redundant relationships: derived from other
relationships
Chapter 6: Developing Data Models for Business Databases
Slide 29
Resolving Design Errors
 Misplaced relationships: use entity type clusters
to reduce connections
 Incorrect cardinalities:
 Incomplete requirements
 Reversed cardinalities
 Missing relationships: examine implications of
requirements
 Overuse of specialized modeling tools: only use
when usage criteria are met
 Redundant relationships: examine relationship
cycles for derived relationships
Chapter 6: Developing Data Models for Business Databases
Slide 30
Example Entity Type Cluster
RateSet
RateSetNo
RSAapprDate
RSEffDate
Customer
Assigned
CustNo
CustName
CustType
Meter
Uses
Contains
MeterNo
MtrSize
MtrModel
ReadBy
Rate
Bill
MinUsage
MaxUsage
FixedAmt
BillNo
BillDate
BillStartDate
Reading
Includes
ReadNo
ReadTime
ReadLevel
Employee
EmpNo
EmpName
EmpTitle
Chapter 6: Developing Data Models for Business Databases
Performs
Slide 31
Summary of Data Modeling
Guidelines
 Use notation precisely
 Strive for simplicity
 ERD connections
 Avoid over connecting the ERD
 Identify hub(s) of the ERD
 Use specialized patterns carefully
 Justify important design decisions
Chapter 6: Developing Data Models for Business Databases
Slide 32
Summary of Basic Conversion
Rules
 Each entity type becomes a table.
 Each 1-M relationship becomes a foreign key in
the table corresponding to the child entity type
(the entity type near the crow’s foot symbol).
 Each M-N relationship becomes an associative
table with a combined primary key.
 Each identifying relationship adds a column to a
primary key.
Chapter 6: Developing Data Models for Business Databases
Slide 33
Application of Basic Rules (I)
Course
Offering
CourseNo
CrsDesc
CrsUnits
Of f erNo
Of f Location
Of f Time
Has
CREATE TABLE Course (… PRIMARY KEY (CourseNo) )
CREATE TABLE Offering (… PRIMARY KEY OfferNo, FOREIGN
KEY (CourseNo) REFERENCES Course )
Chapter 6: Developing Data Models for Business Databases
Slide 34
Application of Basic Rules (II)
Offering
Student
StdNo
StdName
Enrolls_In
OfferNo
OffLocation
OffTime
EnrGrade
CREATE TABLE Enrollment (… PRIMARY KEY (StdNo, OfferNo),
FOREIGN KEY (StdNo) REFERENCES Student,
FOREIGN KEY OfferNo REFERENCES Offering )
Chapter 6: Developing Data Models for Business Databases
Slide 35
Application of Basic Rules (III)
Student
Offering
StdNo
StdName
OfferNo
OffLocation
Registers
Enrollment
Grants
EnrGrade
• Same conversion result as the previous slide
• Different application of rules
Chapter 6: Developing Data Models for Business Databases
Slide 36
Application of Basic Rules (IV)
(a) Manager-subordinate
Faculty
FacNo
FacName
Supervises
(b) Course prerequisites
Course
Prereq_To
CourseNo
CrsDesc
CrsUnits
CREATE TABLE Faculty (… FOREIGN KEY (FacSupervisor) REFERENCES Faculty)
CREATE TABLE Course (… PRIMARY KEY CourseNo)
CREATE TABLE Prereq_To (PreReqCNo …, DepdendCNo …
PRIMARY KEY (PrereqCNo …, DependCNo … ,
FOREIGN KEY (PrereqCNo) REFERENCES Course,
FOREIGN KEY (DependCNo) REFERENCES Course )
Chapter 6: Developing Data Models for Business Databases
Slide 37
Generalization Hierarchy Rule
 Mimic generalization hierarchy as much as
possible
 Each subtype table contains specific columns plus the
primary key of its parent table.
 Foreign key constraints for subtype tables
 CASCADE DELETE option for referenced rows
 Reduce need for null values
 Need joins and outer joins to combine tables
Chapter 6: Developing Data Models for Business Databases
Slide 38
Generalization Hierarchy
Example
Employee
EmpNo
EmpName
EmpHireDate
SalaryEmp
EmpSalary
HourlyEmp
EmpRate
Employee table: EmpNo (PK)
SalaryEmp table: EmpNo (PK), EmpNo (FK)
HourlyEmp table: EmpNo (PK), EmpNo (FK)
Chapter 6: Developing Data Models for Business Databases
Slide 39
Optional 1-M Rule
 Separate table for each optional 1-M
relationship
 Avoids null values
 Requires an extra table and join operation
 Controversial: in most cases 1-M rule is
preferred
Chapter 6: Developing Data Models for Business Databases
Slide 40
Optional 1-M Example
Offering
Faculty
FacNo
FacName
Teaches
OfferNo
OffLocation
OffTime
CREATE TABLE Teaches (… PRIMARY KEY (OfferNo) , FOREIGN KEY(OfferNo)
REFERENCES Offering, FOREIGN KEY(FacNo) REFERENCES Faculty )
Chapter 6: Developing Data Models for Business Databases
Slide 41
1-1 Relationships
Office
Employee
EmpNo
EmpName
Manages
Of f iceNo
Of f Address
Of f Phone
CREATE TABLE Office (… PRIMARY KEY (OfficeNo) , FOREIGN
KEY(EmpNo) REFERENCES Employee, UNIQUE (EmpNo) )
Chapter 6: Developing Data Models for Business Databases
Slide 42
Conversion in Aqua Data
Studio
•
Conversion close match to ERD
•
One table per entity type
Chapter 6: Developing Data Models for Business Databases
Slide 43
Summary






Data modeling is an important skill
Use notation precisely
Preference for simpler designs
Consider alternative designs
Review design for common errors
Work many problems
Chapter 6: Developing Data Models for Business Databases
Slide 44