Entity Relationship (E-R)
Modeling
This lecture is based on Korth
1/19/2010 1:36:12 PM 1
Basic Data Modeling Concepts
• Database design is both art and science
The artistic part means that creativity is involved
The scientific part means there are certain rules and procedures which
must be followed.
• Model: Simplification of reality
It is important to emphasize that a model is not the real world
but merely a human construct to help us better understand real world
systems.
A model can come in many shapes, sizes, and styles.
The database designer can employ the data model as a communications tool
to help him/her explain the database to the applications programmer,
management, and the end user
1/19/2010 1:36:12 PM 2
Database System Design
Data Modeling
1/19/2010 1:36:12 PM 3
Steps in Database Design
• Requirements Analysis
– user needs; what must database do?
• Conceptual Design
– high level description (often done w/ER model)
• Logical Design
– translate ER into DBMS data model
• Schema Refinement
– consistency, normalization
• Physical Design - indexes, disk layout
• Security Design - who accesses what and how
1/19/2010 1:36:12 PM 4
Database Design Steps
info
Entity-relationship Model
Conceptual DB design
Typically used for conceptual
database design
Conceptual Data Model
• Three Levels of
Modeling Logical DB design
Relational Model
Typically
DBMS used for logical
Independent Logical Data Model
database design
DBMS Dependent Physical DB design
Physical Data Model
Database Specific
1/19/2010 1:36:12 PM 5
Database Design Steps
Proj.Scope
Requirements Collection
and Analysis
DB Requirements Internal Schema
Conceptual Design Physical Design
Conceptual Schema Conceptual Schema
Logical Design
(in high-level data model (in DBMS specific data model
e.g. ER model) e.g. relational model)
DBMS-independent DBMS specific
1/19/2010 1:36:12 PM 6
Database Design
• Conceptual database design
– An abstract but complete description of the DB
– Implementation independent ( semantic clarity)
– What data should be stored and what relationship exits between items
of data
– Many-to-many relationships are acceptable to represent entity
associations.
E.g., E-R Model, UML
• Logical database design
– All entities and relationships among them.
– All attributes for each entity are specified.
– The primary key for each entity specified.
– Foreign keys (keys identifying the relationship between different
entities) are specified.
– Normalization occurs at this level.
E.g., Relational, O-O, O-R, Network, hierarchical
1/19/2010 1:36:12 PM 7
Database Design
• Physical Data Model
– At this level, the data modeler will specify how the logical data model
will be realized in the database schema.
– The steps for physical data model design are as follows:
• Convert entities into tables.
• Convert relationships into foreign keys.
• Convert attributes into columns.
• Modify the physical data model based on physical constraints /
requirements.
– The physical data model specifies implementation details. A physical
data model is a single logical model represented in a specific database
management product such as DB2,Sybase, Oracle, Informix, MySQL,
MSSQL in a specific installation.
1/19/2010 1:36:12 PM 8
ER Model
• Gives us a language to specify
– what information the DB must hold
– what are the relationships among components of
that information
• Proposed by Peter Chen in 1976
Professor, Louisiana State University
formalized and popularized the model by Peter Chen
• The Concept was invented by A. P. G. Brown, a Database
practitioner (from Wikipedia)
1/19/2010 1:36:12 PM 9
Entity Sets
• A database can be modeled as:
– a collection of entities,
– relationship among entities.
• An entity is an object that exists and is
distinguishable from other objects.
– Example: specific person, company, event, plant
• Entities have attributes
– Example: people have names and addresses
• An entity set is a set of entities of the same
type that share the same properties.
– Example: set of all persons, companies, trees, holidays
1/19/2010 1:36:12 PM 10
Entity Sets
Customer and Loan
customer-id customer- customer- customer- loan- amount
name street city number
1/19/2010 1:36:12 PM 11
Attributes
• An entity is represented by a set of attributes, that is
descriptive properties possessed by all members of an
entity set.
Example:
customer = (customer-id, customer-name,
customer-street, customer-city)
loan = (loan-number, amount)
• Domain – the set of permitted values for each
attribute
• Attribute types:
– Simple and composite attributes.
– Single-valued and multi-valued attributes
• E.g. multivalued attribute: phone-numbers 0891-284 - 4859
– Derived attributes
• Can be computed from other attributes
• E.g. age, from a given date of birth
1/19/2010 1:36:12 PM 12
Composite Attributes
1/19/2010 1:36:12 PM 13
Relationship Sets
• Relationship : Association among two or more entities
Example:
Jack works in Pharmacy department
customer entity relationship set department entity
participants
• A relationship set is a mathematical relation among n 2
entities, each taken from entity sets
{(e1, e2, … en) | e1 E1, e2 E2, …, en En}
where (e1, e2, …, en) is a relationship
– Example:
(Jack, Pharmacy department ) works in
1/19/2010 1:36:12 PM 14
Relationship Set borrower
1/19/2010 1:36:12 PM 15
Relationship Sets (Cont.)
• An attribute can also be property of a relationship set.
• For instance, the depositor relationship set between entity
sets customer and account may have the attribute access-
date
1/19/2010 1:36:12 PM 16
Degree of a Relationship Set
• Refers to number of entity sets that participate in a
relationship set.
• Relationship sets that involve two entity sets are binary
(or degree two). Generally, most relationship sets in a
database system are binary.
• Relationship sets may involve more than two entity sets.
E.g. Suppose employees of a bank may have responsibilities at
multiple branches, with different jobs at different branches. Then
there is a ternary relationship set between entity sets employee,
job and branch
• Relationships between more than two entity sets are rare.
Most relationships are binary. (More on this later.)
1/19/2010 1:36:12 PM 17