Upload
franklin-reeves
View
232
Download
1
Tags:
Embed Size (px)
Citation preview
•Entities
•ERD Modeling
•Identify and Model Entities
•Define Relationships
•Entity Relationship Layout
•ERD Modeling Relationship and Frequencies
•Special Relationship Types
Module 2: Conceptual Data Modeling with ERD
•An entity, like a noun, is a person, place, thing, or event about which the system is to maintain, correlate, and display information.
•An entity must be within the scope of the system; not all nouns are entities.
•Entities versus Associated Information
•Entity = Table
Entities
Instance of an Entity: An entity instance refers to one distinct entity occurrence. (= Record)
Examples:
• Joe Smith, along with his address and so on, is an occurrence of STUDENT.
• Algebra 101 is an instance of COURSE.
Instance of an Entity
Practice: Identify the entities in the following description by circling the nouns. Remember, entities must be within the scope of the system.
“Buffalo Records and CDs has been in business for only three years and we have already expanded our business to five stores. We’ve decided it might be about time to get a computer to keep track of some of these things that we keep losing information on. For instance, just last week when we did our item inventory, I was sure we had a copy of that new Guns and Roses CD, but a customer came in just yesterday looking for it and it was nowhere to be found? Thought we better get a bit more organized.
Anyway, we have 20 employees now. We need to keep track of their names, addresses, phone numbers, social security numbers, and birth dates. We like to send our employees birthday cards, or cards for other special occasions. Like Joe over there - his wife just had a baby yesterday.”
Question: What are some examples of the entities defined above?
Instance of an Entity (continued)
Entities are classified by three types:
Entity Type ExamplesPhysical Student
MachineProduct
Conceptual Cost CenterSectionAccount
Event TrainingPurchasingState Change (Historical)
Question: What are other examples of the above types of entities?
Classifying Entities
Entities have singular unique names. They are pictorially represented by a rounded box, as in the following:
Employee
Customer
Order
Employee
Customer
Order
Modeling Conventions - Entities
•Determine the significant nouns.
•Determine a logical name for the entity.
•Write a description for the entity.
Identifying and Modeling an Entity
A relationship is a two-directional, significant association between two entities, or an entity and itself
Types of RelationshipsPictorially represented by a line between two entities.Three types of relationships exist:•One to One (1:1)•One to Many (1:M)•Many to Many (M:M)
One to One (1:1)
An instance of Entity A relates to one and only one instance of Entity B. Entity B relates to one and only one instance of entity A.
Types of Relationships
Entity A Entity B
Types of Relationships (continued)
An instance of Entity B relates to one or more instances of Entity A.
An instance of Entity A relates to one and only one instance of Entity B.
One to Many (1:M)
Entity BEntity A
Many to Many (M:M)
An instance of Entity A relates to one or more instance of Entity B.
An instance of Entity B relates to one or more instance of Entity A.
Types of Relationships (continued)
Entity BEntity A
SALESALE ITEM for
Made up of
Each end of a relationship must have a name to describe the relationship, an optionality, and a degree.
Appropriate naming helps to understand the relationship, exposing potential problems early on.
Each SALE must be made up of one or more SALE ITEMs.
Each SALE ITEM must be for one and only SALE.
Relationship Naming Syntax
Each ENTITY A [must be/may be] relationship end name [one and only one/one or more] ENTITY B
Naming Relationships
A relationship may not always exist.
Ticket Passenger
Each Passenger may be the holder of one or more Tickets.
Each Ticket must be for one and only one Passenger.
for
Holder of
Conditional Relationships
Read the Relationship in Each Direction
First read left to right:
Ticket Passengerfor
Each Ticket must be for one and only one Passenger.
Then read right to left:
Ticket PassengerHolder of
Each Passenger may be the holder of one or more Tickets.
Conditional Relationships (continued)
In this practice exercise, you will describe a relationship.
Read and define the following relationships:
Student CourseEnrolled in
Attended by
Treatment Patientfor
receive
Practice: Defining a Relationship
*ERD Modeling Relationships and Frequencies
(1:1) Rare
(1:1) Rare
(1:M) Very Rare
(1:M) Common
(1:M) Rare
(1:M) Very Common
(1:M) Rare
(M:M) Common
(M:M) Common
(M:M) Rare
Reading a Diagram
Entity
Relationship
Diagram
Sale Item
State
Product
Employee
Customer
Sale
identifier of
Located in
The location for
Manager of
Part of
made up of
contained in
Comprised of
Part of
Initiated by
Sold by
The initiator of
Located in
Located of
Managed by
In this practice exercise, you will read a diagram and describe the relationships.Read the following diagram and describe the relationships:
*Special Relationship Types
•Dependent Relationships
•Associative Relationships
•Intersection Entity
Dependent Relationships (1:M)
Treatment Patientfor
receive
1:M relationships are very common.
1:M relationships that are mandatory in both directions are uncommon.
Model multi-level hierarchical data as several 1:M relationships:
City
Country
Continent
within
Made up of
within
Made up of
A One to Many relationship my be represented as 1:M or 1 to M and specifies one or more in one direction and only one in the other direction. 1:M relationships can be called “dependent,” “hierarchical,” or “parent/child.”
Associative Relationships (M:M)
Student CourseEnrolled in
Attended by
Automobile MechanicServiced by
services
Each student may be enrolled in one or more courses.
Each Course may be attended by one or more Students.
M:M relationships are very common.
M:M relationships are usually optional in both directions.
M:M relationships will be “resolved” by using intersection entities because relational models do not directly accommodate them.
A Many to Many, or M:M relationship indicates a degree of one or more in both directions.
Intersection Entity (Associative Entity)
Intersection (or Associative) Entities are created to decompose a M:M into two 1:M relationships, with the Intersection Entity being the “child” of both original “parent” entities.
Service MechanicServiced by
services
Automobile
Performed onreceives