is 380, a. m. thomason1 database fundamentals-is 380 entity relationship diagram chapter 4 : lecture...
DESCRIPTION
IS 380, A. M. Thomason3 Entity Relationship Diagram Data Dictionary Business Data Documentation i.e., policy, constraints, etc. Decision Log Model Set Integration Data Model Data Model ComponentsTRANSCRIPT
IS 380, A. M. Thomason 1
Database Fundamentals-IS 380
Entity Relationship DiagramChapter 4 : Lecture Notes for Asela M. Thomason
IS 380, A. M. Thomason 2
• Understand and use the basic constructs of entity modeling:– Entity– Relationship– Attribute
• Additional concepts:– Subtypes/Super-types– Composite, Associative, Recursive, Exclusive, etc.– Optional/Mandatory– Cardinality
Topic Objectives
IS 380, A. M. Thomason 3
Entity Relationship Diagram
Data Dictionary Business DataDocumentation
i.e., policy, constraints, etc.
Decision Log Model Set Integration
DataModel
Data Model Components
IS 380, A. M. Thomason 4
• Entity modeling is a formal process of describing data in terms of entities, attributes, and relationships.
What is Entity Modeling?
IS 380, A. M. Thomason 5
• A business policy is a required course of action shown to guide decisions.
• A business rule is a business condition under which:– Data items are created, related, and maintained.– Business processes are executed.
What is a Business Rule?
IS 380, A. M. Thomason 6
• An entity is a business object important to the organization and describes a person, place, thing, or event about which data is stored.
– May refer to a tangible object in the real world, such as CUSTOMER or PRODUCT
– May refer to an intangible business concept, such as ORDER or INVOICE.
What is an Entity?
IS 380, A. M. Thomason 7
CUSTOMER
Diagramming Entities
IS 380, A. M. Thomason 8
Noun(singular)
Data Entity Name
Adjective(optional)
Naming Entities
IS 380, A. M. Thomason 9
• A good entity definition says only what the entity is.
• It excludes how the entity is used.
Entity Definitions
IS 380, A. M. Thomason 10
PurchasingVENDORPARTPURCHASE ORDERINVOICEPURCHASING AGENT
BankingBANKHOUSEHOLDCUSTOMERACCOUNT
Project ManagementPROJECTCLIENTEMPLOYEE
Order ProcessingCUSTOMERORDERPRODUCTSALESPERSONINVOICE
Entity Examples
IS 380, A. M. Thomason 11
Customer # N
Customer # 5
Customer # 4
Customer # 3
Customer # 2
Customer # 1
Entity Instance
Entity TypeCUSTOMER
Entity Type Instances
IS 380, A. M. Thomason 12
Data Modeling
Sybase Concepts
Process Dynamic Modeling
COURSE
INSTANCETYPE
Entity Type Vs. Entity Instance
IS 380, A. M. Thomason 13
PROJECTis assigned to
is staffed byEMPLOYEE
Identify Entity Relationships
IS 380, A. M. Thomason 14
PROJECTis assigned to
is staffed by
EMPLOYEE VEHICLEdrives
is driven by
TEACHER STUDENTteaches
is taught by
EMPLOYEE
Identify Entity Relationships
IS 380, A. M. Thomason 15
GARMENTfashions
is designed by
DESIGNER GARMENTwears
is worn by
DESIGNER
Relationships Should Be Meaningful
IS 380, A. M. Thomason 16
INSURANCEPOLICY
owns
is owned by
CUSTOMER
ownsis owned by
INSURANCEPOLICY
Read right to left below the line(INSURANCE POLICY is owned by CUSTOMER)
Read left to right above the line(CUSTOMER owns INSURANCE POLICY)
Clockwise Convention HoldsWhen Rotated 90 Degrees
CUSTOMER
Diagramming Relationships
IS 380, A. M. Thomason 17
One-to-oneRelationshipB
C D
E F
One-to-manyRelationship
Many-to-manyRelationship
(1:1)
(1:M), or(M:1) many-to-one
(M:N)
A
Types of Connectivity
IS 380, A. M. Thomason 18
maintainsCURRICULUM
is maintained by
• An instructor maintains one curriculum• A curriculum is maintained by one instructor.
INSTRUCTOR
Connectivity – One-to-one
IS 380, A. M. Thomason 19
is offered byCLASS
offers
• A course is offered by many classes• A class offers one course.
COURSE
Connectivity – One-to-many
IS 380, A. M. Thomason 20
consists ofCOURSE
is part of
• A curriculum consists of many courses• A course is part of many curriculum.
Connectivity – Many-to-many
CURRICULUM
IS 380, A. M. Thomason 21
is placed byCUSTOMER
places
Maximum = ManyMinimum = 0
Relationship Participation: Optional/Mandory
Maximum = ManyMinimum = 0
Cardinality ( min. , max.) (0,10)
Maximum = 10Minimum = 0
Maximum and Minimum Instances
ORDER
IS 380, A. M. Thomason 22
is taught byINSTRUCTOR
teachesCLASSCOURSE
CURRICULUM
has scheduled
is maintained by
is scheduled for
maintains
consists of is part of
Exercise – Reading Maximums & Minimums
IS 380, A. M. Thomason 23
ACTORMOVIE
SCRIPT
casts
learns fromteachesis made into is filmed from
DRAMATEACHER
acts in
Exercise – Reading Cardinality
IS 380, A. M. Thomason 24
ACTORMOVIE
SCRIPT
casts
learns fromteachesis made into is filmed from
DRAMATEACHER
acts in
Possible Solution Identifying Maximums and Minimums
IS 380, A. M. Thomason 25
Class
Attribute Name
Naming Attributes
Qualifier
IS 380, A. M. Thomason 26
What are the attributes of the following:“Data Modeling is a three-day course.”
Identifying Attributes
IS 380, A. M. Thomason 27
ACTORMOVIE
SCRIPT DRAMATEACHER
Exercise – Identifying Maximums and Minimums
IS 380, A. M. Thomason 28
To determine where an attribute lives, ask:
“What primary key determines the value of this attribute?”
OR
“What entity does this attribute describe?”
Assigning Attributes
IS 380, A. M. Thomason 29
PRODUCT:
CUSTOMER:
SIN
CHECKING ACCOUNT:
Choosing Primary Keys
EMPLOYEE:
IS 380, A. M. Thomason 30
INSTRUCTORCOURSE
TitleDepartmentDuration
is taught byName
teaches
• A Key is one or more attributes that will uniquely identify an instance of an entity.
Entity Identifiers
IS 380, A. M. Thomason 31
Primary Key Guidelines
• Identify all candidate keys
• Select one to be the primary key
• If no good candidate exists, a non-intelligent key can be generated (Customer ID, Order Number).
IS 380, A. M. Thomason 32
DEPARTMENT:
FIXED ASSET:
EMPLOYEE # NAME ADDRESS JOB CODE DEPARTMENT #
DEPARTMENT NAME
INVENTORY # DESCRIPTION ORIGINAL COST
DEPARTMENT #
DEPARTMENT #
Primary KeyForeign Key
Foreign Key
Primary Key
Primary Key
EMPLOYEE DEPARTMENT
FIXED ASSET
Foreign Keys Examples
EMPLOYEE:
IS 380, A. M. Thomason 33
Course ID (PK)
has scheduled
is maintained by
maintains
consists of is part of
is scheduled for
COURSE
Curriculum ID (PK)
CURRICULUM
Class ID (PK)
CLASS
Instructor ID (PK)
INSTRUCTOR
Defining Foreign Keys
IS 380, A. M. Thomason 34
COURSEhas scheduled
is scheduled for
Course ID (PK)
CLASS
Class Name (PK)Course ID (FK)
Defining Relationship Instances
IS 380, A. M. Thomason 35
Course ID (PK)
has scheduled
is maintained by
maintains
consists of is part of
is scheduled for
COURSE
Curriculum ID (PK)
CURRICULUM
Class ID (PK)
CLASS
Instructor ID (PK)
INSTRUCTOR
Resolving Many-to-Many Relationships
IS 380, A. M. Thomason 36
PROJECT:
EMPLOYEE # NAME
Primary Key
EMPLOYEE
Why Is It Important to Resolve Many-to-many Relationships?
EMPLOYEE:
E2E3E7
MCELREATHTAMMISAVIANO
PROJ # DESCRIPTION
P1P2P3
ORDER PROCESSINGMORTAGE LOANSPAYROLL
Primary Key
is assigned to
has assignedPROJECT
IS 380, A. M. Thomason 37
EMPLOYEE
How are Many-to-many Relationships Resolved?
is assigned to
has assignedPROJECT
EMPLOYEE ASSIGNMENT PROJECT
Associative Entity (Composite Entity)
Primary key:Employee#Project#
Primary key:
Employee#Primary key:
Project#
IS 380, A. M. Thomason 38
ASSIGNMENT:
PROJECT:
EMPLOYEE # NAME
Primary Key
Primary Key
EMPLOYEE
ASSIGNMENT
PROJECT
Relational Table View
EMPLOYEE:
E2E3E7
MCELREATHTAMMISAVIANO
EMP # PROJ #
E2E2E3E4E7
P1P2P1P3P2
START DATE
02/8901/9006/8911/8907/89
HOURS
10050
5007510
PROJ # DESCRIPTION
P1P2P3
ORDER PROCESSINGMORTAGE LOANSPAYROLL
Primary Key
IS 380, A. M. Thomason 39
COMMERCIALLOAN
What is a Subtype?
Subtype(Child)
Supertype(Parent)
LOAN
RESIDENTIALLOAN
COMMERCIALCUSTOMER
CUSTOMER
RESIDENTIALCUSTOMER
IS 380, A. M. Thomason 40
BANKACCOUNT
Entity Subtyping Rules
OR
CHECKINGACCOUNT
CHECKINGACCOUNT
BANK ACCOUNT
SAVINGSACCOUNT
• Entity subtypes are subdivisions of an entity that represent the same object as the original entity.
SAVINGSACCOUNT
is a is a
IS 380, A. M. Thomason 41
Exercise - Subtyping
• Subtypes and draw each of the following entities once by life cycle state and once by variety:
– EMPLOYEE
– INSURANCE POLICY
– FAMILY MEMBER
IS 380, A. M. Thomason 42
Possible Solution - Subtyping
VARIETY
LIFE CYCLESTATE
TERM LIFE
INSURANCEPOLICY
VARIABLELIFE
MANAGEMENTEMPLOYEE
EMPLOYEE
UNIONEMPLOYEE
PARENT
FAMILYMEMBER
CHILD
ACTIVEPOLICY
INSURANCEPOLICY
LAPSEDPOLICY
ACTIVEEMPLOYEE
EMPLOYEE
RETIREDEMPLOYEE
ADULT
FAMILYMEMBER
MINOR
IS 380, A. M. Thomason 43
GRADUATE
Subtyping Strategies
An entity can be subtyped by:
Variety
STUDENT
UNDER-GRADUATE
MYSTERY
BOOK
ADVENTURE
ADVENTURE
Life Cycle State
IS 380, A. M. Thomason 44
When is Subtyping Useful?
• When the business views subsets of an entity differently; for instance, when business policies are different for different subsets.
• When only certain subsets of an entity have a relationship with another entity.
• When the cardinality between two entities is different for one or more subsets.
• When the attributes of an entity vary significantly from subset to subset.
IS 380, A. M. Thomason 45
DOCK
Entity Subtypes Example
is moored atGARAGE
OWNER
VEHICLE
is accom-modating is parked in
owns
contains
is owned by
DOCKis moored
at
GARAGE
OWNER
VEHICLEis accom-modating
is parked
in
owns
contains
is owned by
BOAT AUTO
BECOMES
Parent(Supertype) Child
(Subtype)
IS 380, A. M. Thomason 46
Resolving Entity Subtypes
Subtypes must be resolved before creating your Physical ERD, model. There are 3 different options:
Option 1: Create dependent entities and preserve the parent entity. ( a dependent entity contains the primary key of another entity, or has an existence dependency on that entity)
BOAT AUTO VEHICLE
IS 380, A. M. Thomason 47
Resolving Entity Subtypes
Option 2: Create an entity for every subtype and eliminate the parent. The vehicle information will be duplicated in auto and boat.
BOAT AUTO
IS 380, A. M. Thomason 48
Resolving Entity Subtypes
Option 3: Create an entity that will store all the information for both the supertype and subtype.
VEHICLE
IS 380, A. M. Thomason 49
Data Model Types
Conceptual(First draft)
Logical
Physical (Access/Oracle)
Note: These three models do not match the Database book in class. Similar but not exact.
IS 380, A. M. Thomason 50
Why is Conceptual Entity Modeling Important?
• It identifies the high-level data requirements of each major business function.
• It portrays the business view of the data.• It illustrates important entity relationships.• It forces you to question and crystallize business
policy.
IS 380, A. M. Thomason 51
Characteristics of a Conceptual Entity Model
• Shows Only Important Entities• Based on Partial Understanding• Includes Subtypes• Allows Many-to-many Relationships• Shows Primary Keys• Shows Few or No Non-key Attributes• Is Independent of Physical Constraints
IS 380, A. M. Thomason 52
Developing the Conceptual Entity Model
• Identify the major entities• Define the relationships between the major entities• Define entity keys
IS 380, A. M. Thomason 53
Conceptual Vs. Logical – What’s the Difference?
All Attributes NormalizedFew Attributes Non-keyAttributes
All Keys and RI RulesPrimary, Some ForeignKeys
Detailed with M:N ResolvedHigh-level, M:NRelationships
All Entities, with Subtypes Resolved
Major Entities and SubtypesEntities
Development ReleaseBusiness AreaScope
LogicalEntity Model
ConceptualEntity Model
IS 380, A. M. Thomason 54
Characteristics of a Logical Entity Model
• Shows All Entities• Resolves Subtypes• Resolves All Many-to-many (M:N) Relationships• Identifies and Defines All Attributes• May Identify All Foreign Keys• Is in Third Normal Form• Identifies Domains• Is Independent of Physical Constraints
IS 380, A. M. Thomason 55
What Information is Available?
• Detailed Entities and Relationships• Attributes• Statistics and Characteristics
Conceptual Entity Model
Logical Entity Model