11 Introduction to Entities, Attributes, and Relationships.
-
Upload
shanna-chandler -
Category
Documents
-
view
228 -
download
0
Transcript of 11 Introduction to Entities, Attributes, and Relationships.
1111
Introduction to Entities, Attributes, and Relationships
Introduction to Entities, Attributes, and Relationships
1-1-22
OverviewOverview
• Why conceptual modeling?
• Introduction of the Key role players:
– Entities
– Attributes
– Relationships
• Why conceptual modeling?
• Introduction of the Key role players:
– Entities
– Attributes
– Relationships
1-1-33
Why Create a Conceptual Model?Why Create a Conceptual Model?
• It describes exactly the information needs of the It describes exactly the information needs of the businessbusiness
• It facilitates discussionIt facilitates discussion
• It helps to prevent mistakes, misunderstandingIt helps to prevent mistakes, misunderstanding
• It forms important “ideal system” documentationIt forms important “ideal system” documentation
• It forms a sound basis for physical database It forms a sound basis for physical database designdesign
• It is a very good practice with many practitionersIt is a very good practice with many practitioners
• It describes exactly the information needs of the It describes exactly the information needs of the businessbusiness
• It facilitates discussionIt facilitates discussion
• It helps to prevent mistakes, misunderstandingIt helps to prevent mistakes, misunderstanding
• It forms important “ideal system” documentationIt forms important “ideal system” documentation
• It forms a sound basis for physical database It forms a sound basis for physical database designdesign
• It is a very good practice with many practitionersIt is a very good practice with many practitioners
1-1-44
Between Dream and Reality...Between Dream and Reality...
1-1-55
Entity Relationship ModelingEntity Relationship Modeling
• Models business,not implementation
• Is a well-established technique
• Has a robust syntax
• Results in easy-to-read diagrams…
...although they maylook rather complex at first sight
• Models business,not implementation
• Is a well-established technique
• Has a robust syntax
• Results in easy-to-read diagrams…
...although they maylook rather complex at first sight
SUPPLIER# SUPPLIER CODEo EMAIL* APPROVED* REFERENCE
OTHER ORGANIZATION
ORGANIZATIONo EMAIL* NAMEo POSTAL CODEo REGIONo STREETo TOWNo TELEPHONE NUMBERo CONTACT NAMEo CONTACT EXTENSION
MEMBERSHIP TYPE# CODE* DESCRIPTION* DISCOUNT PERCENTAGEo STANDARD FEE
MEMBERSHIP PERIOD# START DATEo ACTUAL FEE PAID
MEMBERSHIP# NUMBERo TERMINATION REASONo TERMINATION DATE
EMPLOYEE* POSITION* LAST NAMEo FIRST NAMEo OTHER INITIALSo EMAIL
BOOKING* BOOK DATEo EXPIRE DATEo NOTIFY DATEo RESERVE DATEo STAFF REMARKS
RENTAL ITEM# LINE NO* RENTAL PERIOD* PRICE PAIDo RETURN DATEo STAFF REMARKS
RENTAL* RENTAL DATEo STAFF REMARKSo COMPLETED
COPY* ACQUIRE DATE* PURCHASE COST* SHELF CODEo CONDITIONo CUSTOMER REMARKS...
REVIEW# SEQUENCE* ARTICLE* HOTo AUTHORo URL
PUBLICATION# REFERENCE* TITLEo VOLUMEo ISSUEo PUBLISH DATE
CUSTOMERo EMAIL* DESIGNATION* FIRST NAME* LAST NAMEo OTHER INITIALS* STREET* TOWN* POSTAL CODE* REGIONo HOME PHONEo WORK EXTENSIONo WORK PHONEo PHOTOGRAPHo STAFF REMARKS
CATALOG# REFERENCEo CATALOG DATEo DESCRIPTION
MOVIE* CATEGORYo AGE RATING* DURATION* MONOCHROMEo AUDIOo PREVIEW
GAME* CATEGORY* MEDIUMo MINIMUM MEMORY
TITLE# PRODUCT CODE* TITLEo DESCRIPTION
PRICE LEVEL# CODE* DESCRIPTION
PRICE HISTORY# EFFECTIVE DATE* PRICE* DEFAULT DAYS* OVERDUE RATE
for
used for
of
renewed for
of
the type of
held by
the holder of
held by
the holder of
availablefrom
thedistributor for
requestedagainst the
requestorof
authorized by
responsiblefor
the reservation for
reserved on
for
on
cancelled by
the cancellor of
approved by
responsible for
of
reviewed in
at
applied to
the rental for
fulfilled as
part of
composed of
for
rented on
approved by
responsiblefor
part of
parent organization of
acquired from
the source of
of
available as
for
defined by
managed by
the manager of
in
the source of
in
the source of
1-1-66
Goals of Entity Relationship ModelingGoals of Entity Relationship Modeling
• Capture all required information
• Information appears only once
• Model no information that is derivable from other information already modeled
• Information is in a predictable, logical place
• Capture all required information
• Information appears only once
• Model no information that is derivable from other information already modeled
• Information is in a predictable, logical place
1-1-77
Database TypesDatabase Types
HierarchicalHierarchical
RelationalRelational
NetworkNetwork
ER ModelER Model
1-1-88
EntityEntity
• An Entity is:
– “Something” of significance to the business about which data must be known.
– A name for the things that you can list.
– Usually a noun.
• Examples: objects, events
• Entities have instances.
• An Entity is:
– “Something” of significance to the business about which data must be known.
– A name for the things that you can list.
– Usually a noun.
• Examples: objects, events
• Entities have instances.
1-1-99
Entities and InstancesEntities and Instances
PERSON
PRODUCT
PRODUCT TYPE
EMPLOYMENT CONTRACT
JOB
SKILL LEVEL
TICKET RESERVATION
PURCHASE
ELECTION
PRINTER PREFERENCE
DOCUMENT VERSION
PERSON
PRODUCT
PRODUCT TYPE
EMPLOYMENT CONTRACT
JOB
SKILL LEVEL
TICKET RESERVATION
PURCHASE
ELECTION
PRINTER PREFERENCE
DOCUMENT VERSION
Mahatma Gandhi
2.5 x 35 mm copper nail
nail
my previous contract
violinist
fluent
tonight: Hamlet in the Royal
the CD I bought yesterday
for parliament next fall
…
...
Mahatma Gandhi
2.5 x 35 mm copper nail
nail
my previous contract
violinist
fluent
tonight: Hamlet in the Royal
the CD I bought yesterday
for parliament next fall
…
...
1-1-1010
Entities and SetsEntities and Sets
dish washerdish washer
JOB
waiterwaiter
cookcookwaitresswaitress
managermanager
financial controllerfinancial controller
porterporter
piano playerpiano player
• An entity represents a set of instances that are of interest to a particular business.
• An entity represents a set of instances that are of interest to a particular business.
1-1-1111
AttributeAttribute
• Also represents something of significance to the business
• Is a single valued property detail of an entity
• Is a specific piece of information that:
– Describes
– Quantifies
– Qualifies
– Classifies
– Specifies
an entity.
• Also represents something of significance to the business
• Is a single valued property detail of an entity
• Is a specific piece of information that:
– Describes
– Quantifies
– Qualifies
– Classifies
– Specifies
an entity.
1-1-1212
Attribute ExamplesAttribute Examples
Entity
EMPLOYEE
CAR
ORDER
JOB
TRANSACTION
EMPLOYMENT CONTRACT
Entity
EMPLOYEE
CAR
ORDER
JOB
TRANSACTION
EMPLOYMENT CONTRACT
Attribute
Family Name, Age, Shoe Size,
Town of Residence, Email, ...
Model, Weight, Catalog Price, …
Order Date, Ship Date, …
Title, Description, ...
Amount, Transaction Date, …
Start Date, Salary, ...
Attribute
Family Name, Age, Shoe Size,
Town of Residence, Email, ...
Model, Weight, Catalog Price, …
Order Date, Ship Date, …
Title, Description, ...
Amount, Transaction Date, …
Start Date, Salary, ...
1-1-1313
RelationshipsRelationships
• Also represent something of significance to the business
• Express how entities are mutually related
• Always exist between two entities (or one entity twice)
• Always have two perspectives
• Are named at both ends
• Also represent something of significance to the business
• Express how entities are mutually related
• Always exist between two entities (or one entity twice)
• Always have two perspectives
• Are named at both ends
1-1-1414
Relationship ExamplesRelationship Examples
EMPLOYEES have JOBS
JOBS are held by EMPLOYEES
EMPLOYEES have JOBS
JOBS are held by EMPLOYEES
PRODUCTS are classified by a PRODUCT TYPE
PRODUCT TYPE is a classification for a PRODUCT
PRODUCTS are classified by a PRODUCT TYPE
PRODUCT TYPE is a classification for a PRODUCT
PEOPLE make TICKET RESERVATIONS
TICKET RESERVATIONS are made by PEOPLE
PEOPLE make TICKET RESERVATIONS
TICKET RESERVATIONS are made by PEOPLE
1-1-1515
JOB
waiterwaiter
cookcookwaitresswaitress
managermanager
financial controllerfinancial controller
porterporter
piano playerpiano player
Employees have JobsEmployees have Jobs
AhmedAhmed
JillJillAdamAdam
MariaMaria
EMPLOYEEEMPLOYEE
Numerical observation:
• All EMPLOYEES have a JOB
• No EMPLOYEE has more than one JOB
• Not all JOBS are held by an EMPLOYEE
• Some JOBS are held by more than one EMPLOYEE
Numerical observation:
• All EMPLOYEES have a JOB
• No EMPLOYEE has more than one JOB
• Not all JOBS are held by an EMPLOYEE
• Some JOBS are held by more than one EMPLOYEE
ShintaroShintaro dish washerdish washer
1-1-1616
Entity Representation in DiagramEntity Representation in Diagram
• Drawn as a “softbox”
• Name singular
• Name inside
• Neither size, nor position has a special meaning
• Drawn as a “softbox”
• Name singular
• Name inside
• Neither size, nor position has a special meaning
EMPLOYEE
TICKETRESERVATION
JOB ASSIGNMENT
JOB
ORDERE
LEC
TIO
N
During design, entities usually lead to tables.
1-1-1717
Attributes in DiagramsAttributes in Diagrams
*o
EMPLOYEE Family Name Addresso Birth Dateo Shoe Sizeo Email
JOB Titleo Description
During design, attributes lead to columns.
*
*
*
Mandatory attribute, that is, known and available for every instance
Optional attribute, that is, unknown or unimportant to know for some instances
1-1-1818
Jobs are held by one or more employees
An employee has exactly one jobAn employee has exactly one jobhas
Relationship in DiagramsRelationship in Diagrams
EMPLOYEE JOB has
held by
held by
exactly one
one or more
During design, relationships lead to foreign keys.
1-1-2121
EMPLOYEE JOB
Two PerspectivesTwo Perspectives
hashas
held byheld by
mandatory:mandatory:mandatory:mandatory: optional:optional:optional:optional:
1-1-2222
Every EMPLOYEE has exactly one JOB
One WayOne Way
hashasEMPLOYEE JOB
held byheld by
mandatory:mandatory:mandatory:mandatory: optional:optional:optional:optional:
1-1-2323
The Other WayThe Other Way
hashasEMPLOYEE JOB
held byheld by
mandatory:mandatory:mandatory:mandatory: optional:optional:optional:optional:
A JOB may be held by one or more EMPLOYEES
1-1-2424
””““EachEach PP split intosplit intomust bemust be
may bemay be one or more Qsone or more Qsexactly one Qexactly one Q““EachEach P P may be may be split intosplit into one or more one or more Qs Qs””
““EachEach QQ part ofpart of ””must bemust be
may bemay be one or more Psone or more Psexactly one Pexactly one P““EachEach Q Q must be must be part of part of exactly oneexactly one P P””
Reading a Relationship EndReading a Relationship End
P split intosplit into Qpart ofpart of
1-1-2525
Functions Drive DataFunctions Drive Data
• Business functions are always present.
– Explicit
– Assumed
• Business functions need data.
• An entity, attribute, or relationship may be modeled because:
– It is used by a business function.
– The business need may arise in the near future.
• Business functions are always present.
– Explicit
– Assumed
• Business functions need data.
• An entity, attribute, or relationship may be modeled because:
– It is used by a business function.
– The business need may arise in the near future.
1-1-2626
Weather ForecastWeather Forecast
KøbenhavnBremenBerlinMünchenAmsterda
mBruxellesParisBordeaux
1/-5
7/2
3/-1
8/3
5/-3
4/0
4/1
0/-3
January 263
3
3
4
3
2
3
4
****
1-1-2727
(Copenhagen)
Bremen
Berlin
(Munich)
Bruxelles
Paris
Bordeaux
Amsterdam
UKUK
FRFR
DEDE
DKDK
CHCH
NLNL
BEBE
ITIT
LULU
IRIR
København
München
(Brussels)
1-1-2828
located in
having
referring to
referred in
about
Weather Forecast, a Solution Weather Forecast, a Solution
WEATHER TYPE* Icon* Description
WIND DIRECTION* Icon* Description
COUNTRY* Nameo Geographical Position
CITY* Nameo Geographical Position
FORECAST* Dateo Minimum Temperatureo Maximum Temperatureo Wind Force
referring to
referred in
subject of
1-1-2929
Graphical Elements of ER DiagramGraphical Elements of ER Diagram
SubtypeSubtype
##
Unique identifierUnique identifier
ArcArcArcArc
NontransferabilityNontransferabilityNontransferabilityNontransferability
** **o
o
EntityEntity
AttributeAttribute
RelationshipRelationship
1-1-3030
SummarySummary
• ER Modeling models information conceptually
• Based on functional business needs
• “What”, not “How”
• Diagrams provide easy means of communication
• Detailed, but not too much
• ER Modeling models information conceptually
• Based on functional business needs
• “What”, not “How”
• Diagrams provide easy means of communication
• Detailed, but not too much
1-1-3131
PracticesPractices
• Instance or Entity
• Guest
• Reading
• Hotel
• Recipe
• Instance or Entity
• Guest
• Reading
• Hotel
• Recipe
1-1-3232
Practice: Instance or Entity?Practice: Instance or Entity?
PRESIDENT
ELLA FITZGERALD
DOG
ANIMAL
HEIGHT
E CAR
A CAR
I CAR
Concept E/A/I? Example Instance or EntityConcept E/A/I? Example Instance or Entity
1-1-3333
Practice: GuestPractice: Guest
GUESTGUEST
HOTELHOTEL
ROOMROOM
AddressAddress
Arrival Date Arrival Date
Family NameFamily Name
Room NumberRoom Number
Floor NumberFloor Number
Number of BedsNumber of Beds
Number of Parking Lots Number of Parking Lots
PricePrice
TV set available?TV set available?
1-1-3434
Practice: ReadingPractice: Reading
Each EMPLOYEE may be assigned to one or more DEPARTMENTS
Each DEPARTMENT must be responsible for one or more EMPLOYEES
Each EMPLOYEE must be assigned to one or more DEPARTMENTS
Each DEPARTMENT may be responsible for one or more EMPLOYEES
Each EMPLOYEE must be assigned to exactly one DEPARTMENT
Each DEPARTMENT may be responsible for exactly one EMPLOYEE
Each EMPLOYEE may be assigned to one or more DEPARTMENTS
Each DEPARTMENT must be responsible for one or more EMPLOYEES
Each EMPLOYEE must be assigned to one or more DEPARTMENTS
Each DEPARTMENT may be responsible for one or more EMPLOYEES
Each EMPLOYEE must be assigned to exactly one DEPARTMENT
Each DEPARTMENT may be responsible for exactly one EMPLOYEE
EMPLOYEEEMPLOYEE DEPARTMENTDEPARTMENTassigned toassigned to
responsible forresponsible for
AA
BB
CC
1-1-3535
Practice: Read and CommentPractice: Read and Comment
TOWNTOWN
birthplace ofbirthplace of
born inborn in
living inliving in
home town ofhome town of
mayor ofmayor of
with mayorwith mayor
PERSONPERSON
visitor ofvisitor of
visited byvisited by
1-1-3636
Practice: HotelPractice: Hotel
HOTEL* Address
STAY* Arrival Date
ROOM* Room Number
PERSON* Name
inin
the lodging the lodging forfor
ofof
withwith
inin
withwith
guest inguest in
host ofhost of
1-1-3737
Açorda alentejanabread soup from Portugal
Ralph’s Raving Recipes
Cut the onion into small pieces and fry together with the garlic. Wash the red pepper, cut it in half, remove the seeds and fry it for at least 15
page 127
preparation
vegetarian15 mineasy
1 onion4 cloves of garlic1 red pepper1 liter of vegetable broth4 tablespoons of olive oil4 fresh eggs1 handful of parsley or coriandersalt, pepper9-12 slices of (old) bread
for 4 persons:
Soups