ENTITY RELATIONSHIP MODEL(ERM)2
Objectives How to use EntityRelationship (ER) modeling indatabase design.
Basic concepts associated with ER model. Diagrammatic technique for displaying ER model usingUnified Modeling Language (UML).specification.
How to build an ER model from a requirements
Entity Relationship ModelingPRICE LEVEL
Models business,not implementation Is a well-established technique Has a robust syntax Results in easy-to-read diagrams
# CODE * DESCRIPTION
defi ned by
appli ed toORGANIZATIONo * o o o o o o o EMAIL NAME POSTAL CODE REGION STREET TOWN TELEPHONE NUMBER CONTACT NAME CONTACT EXTENSION
atT IT LE MOVIE# PRODUCT CODE * CATEGORY * TITLE o AGE RATI NG o DESCRI PTION * DURATION * MONOCHROME o AUDIO o PREVIEW
parent organi zation of
the foSUPPLIER# SUPPLIER CODE o EMAIL APPROVED REFERENCE
distributor * CATEGORY * MEDIUM r o MINIMUM MEMORY
forPRICE HISTORY# EFFECTIVE DATE * PRI CE * DEFAULT DAYS * OVERDUE RATE
revi ewed i avail abl e as n
avail abl e * * from the source of
OT HER ORGANIZAT ION
PUBLICAT ION# * o o o REFERENCE TITLE VOLUME ISSUE PUBLI SH DATE
CATALOG# REFERENCE o CATALOG DATE o DESCRI PTION
the holder o fCUST OMERo * * * o * * * * o o o o o
managed by EMPLOYEE* * o o o POSITION LAST NAME FIRST NAME OTHER INITIALS EMAIL
the source of the source of
the manager of
acquired fro m
the cancel lor of responsi ble for
responsi ble for
EMAIL DESIGNATION FIRST NAME LAST NAME OTHER INITIALS STREET TOWN POSTAL CODE REGION HOME PHONE WORK EXTENSION WORK PHONE PHOTOGRAPH STAFF REMARKS
* ACQUIRE DATE * PURCHASE COST * SHELF CODE o CONDITION o CUSTOMER REMARKS .. .
the holder of responsi ble forMEMBERSHIP TYPE# CODE * DESCRIPTION * DISCOUNT PERCENTAGE o STANDARD FEE
rented on reserved on
held by in inREVIEW# * * o o SEQUENCE ARTICLE HOT AUTHOR URL
ofMEMBERSHIP# NUMBER o TERMINATION REASON o TERMINATION DATE
the type o f of
...although they may look rather complex at first sight
the reservati on for for cancel led by
renewed fo r authorized by of requested against the MEMBERSHIP PERIOD requestor # START DATE o ACTUAL FEE PAI D of approved by
used fo r
BOOKING* o o o o BOOK DATE EXPIRE DATE NOTIFY DATE RESERVE DATE STAFF REMARKS
ful fi ll ed asRENT AL* RENTAL DATE o STAFF REMARKS o COMPLETED
composed of forRENT AL IT EM# LINE NO * RENTAL PERIOD * PRI CE PAI D o RETURN DATE o STAFF REMARKS
the rental for
Goals 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
Database TypesER Model
ER Diagram of Branch View of DreamHome
Concepts of the ER Model Entity types Relationship types Attributes
Entity Type Entity typeGroup of objects with same properties, identified by enterprise as having an independent existence. Something of significance to the business about which data must be known A name for the things that you can list Usually a noun
Uniquely identifiable object of an entity type.
Example of Entities and Instances (1) 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 ...
Examples of Entity Types (2)
Entities and Sets An entity represents a set of instances that are ofinterest to a particular business.JOBmanager cook waitress dish washer financial controller waiter porter piano player
ER Diagram of Staff and Branch Entity Types
Remarks on creating Entities Give the entity a unique name Create a formal description of the entity Add a few attributes, if possible Be aware of homonyms Check entity names and descriptions regularly Avoid use of reserved words Remove relationship name from entity name
Relationship Types Relationship type Set of meaningful associations among entity types. Express how entities are mutually related Always exist between two entities (or one entity twice)
Relationship occurrence Uniquely identifiable association, which includes one occurrence from each participating entity type.
Relationship Examples EMPLOYEES have JOBS JOBS are held by EMPLOYEESPRODUCTS are classified by a PRODUCT TYPEPRODUCT TYPE is a classification for a PRODUCT
PEOPLE make TICKET RESERVATIONSTICKET RESERVATIONS are made by PEOPLE
Entity Representation in Diagram Drawn as a softbox Name singular Name inside Neither size, nor position has a special meaningELECTIONEMPLOYEE JOB
During design, entities usually lead to tables.
Employees have JobsJOB EMPLOYEEShintaro Jill Ahmed Maria Adam waitress dish washer financial controller manager cook
porter piano player
Numerical observation: All EMPLOYEES have a JOB No EMPLOYEE has more than one JOB
Not all JOBS are held by an EMPLOYEESome JOBS are held by more than one EMPLOYEE
Semantic Net of Has Relationship Type
ER Diagram of Branch Has Staff Relationship
Relationship Types Degree of a Relationship Number of participating entities in relationship.
Relationship of degree: two is binary; three is ternary; four is quaternary.
Binary Relationship called POwns
Ternary Relationship called Registers
Quaternary Relationship called Arranges
Relationship Types Recursive Relationship
Relationship type where same entity type participates more than once in different roles.
Relationships may be given role names to indicate
purpose that each participating entity type plays in a relationship.
Recursive Relationship called Supervises with Role Names
Entities associated through two distinct Relationships with Role Names
Attributes Attribute Also represents something of significance to the business Is a specific piece of information that: Describes Quantifies Qualifies Classifies Specifies an entity Property of an entity or a relationship type.
Attribute Domain Set of allowable values for one or more attributes.
Attribute ExamplesEntity EMPLOYEECAR 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, ...
EM Entities and AttributesNouns user address password person name country birth date occupation message text attachment file folder inbox outbox wastebasket Entities/Attributes/ Instances USER Address Password PERSON Name COUNTRY Birth Date Occupation MESSAGE Text ATTACHMENT File FOLDER Inbox Outbox Wastebasket
Entities with their Attributes USER - Address - Password PERSON - Name - Birth Date - Occupation COUNTRY - Name MESSAGE - Text ATTACHMENT - Filename FOLDER - Name
Attributes in Diagrams Mandatory attribute, that is, known and available forevery instance.
Optional attribute, that is, unknown or unimportant toknow for some instances.EMPLOYEE Family Name * Address * o Birth Date o Shoe Size o Email JOB Title * Description o
During design, attributes lead to columns.
Attributes Simple Attribute Attribute composed of a single component with an independent existence.
Attribute composed of multiple components, each with an independent existence. Example: address (simple attribute) can be subdivided into attributes of street, city, postcode
Attributes Single-valued Attribute
Attribute that holds a single value for each occurrence of an entity type.
Attribute that holds multiple values for each occurrence of an entity type. Eg: telephoneNo
Attribute that represents a value that is derivable from value of a related attribute, or set of attributes, not necessarily in the same entity type.33
Keys Candidate Key
Minimal set of attributes that uniquely identifies each occurrence of an entity type.
Candidate key selected to uniquely identify each occurrence of an entity type.
Composite Key A candidate key that consists of two or more attributes.
ER Diagram of Staff and Branch Entities and their Attributes
Strong Entity Type
Entity type that is not existence-dependent on some other entity type. Characteristic: Each entity occurrence is uniquely identifiable using PK attribute of the entity type
Weak Entity Type Entity type that is existence-dependent on some other entity type. Characteristic: Each entity occurrence cannot be uniquely identified using attributses associated with the entity type36
Strong Entity Type called Client and Weak Entity Type called Preference
Relationship with AttributesWhen to have relationship with attr