Erd - Final Unit 2
Erd - Final Unit 2
Erd - Final Unit 2
Model
Conceptual Data model
Entity Sets
Relationship Sets
Design Issues
Mapping Constraints
Keys
E-R Diagram
Extended E-R Features
Design of an E-R Database Schema
Reduction of an E-R Schema to Tables
Conceptual Data Models
Conceptual data models provide languages to
describe conceptual schemas.
Conceptual schemas are used to describe the classes
of objects that occur in an application area, their
properties, their relationships, and the constraints
that hold with respect to those classes of objects.
Center on “what kind of objects a database
contains” and not on “how these objects are stored”
( Internal Schema) and not on “how these objects
are represented / displayed to a person that accesses
the database” ( External Schema).
Conceptual Data Models ---
What are they good for?
As a database design tool formalizing the
information requirements of the end users
As a documentation tool for databases (to
help programmers, especially those that have
to update the database)
As a data model of a database management
system (only very few experimental systems
exist)
As a tool to describe domain ontologies
(terminology and concepts in a UoD)
As a tool of system analysis
Conceptual Data Modeling and
the E-R Diagram
Goal
Capture as much of the meaning of the data as
possible
If you know the rules of normalization,
Derived attributes
One to many
Many to one
Many to many
Mapping Cardinalities
id
Employee Manages
worker
name
address
Roles
Entity sets of a relationship need not be
distinct
The labels “manager” and “worker” are called roles; they specify how
employee entities interact via the works-for relationship set.
relationship borrower
A loan is associated with at most one customer via borrower
One-To-Many Relationship
In the one-to-many relationship a loan is
associated with at most one customer via
borrower, a customer is associated with
several (including 0) loans via borrower
Many-To-One Relationships
In a many-to-one relationship a loan is
associated with several (including 0)
customers via borrower, a customer is
associated with at most one loan via borrower
Many-To-Many Relationship
ISA triangle
Overlapping
entity set
Design Constraints on a
Specialization/Generalization (Contd.)
Method 1:
Form a table for the higher level entity
Form a table for each lower level entity
set, include primary key of higher level
entity set and local attributes
of specialization tables
But explicit table may still be needed for foreign key
constraints
Drawback: street and city may be stored redundantly for
persons who are both customers and employees
Relations Corresponding to
Aggregation
gpa Name
department
(0,*) (0,*)
works-
Person for
Company
gender
wife husband
(0,*)
ssn (0,*) (0,*)
salary takes
(0,*)
is-married-
to
Section S#
time
Course C#
Example: Too many Entity Types /
Don’t use Foreign Keys
Example: Persons as well as animals can be insured
P#
Name
(0,*) (0,*)
is-
Person insured Company
name
ssn (0,*)
Boss-ssn
Bad E/R Diagram!
Animal
A#
E/R Diagram Design – Typical Errors
1. Missing Constraints
2. Unexpressed Constraints due to bad design
3. Every entity type needs a key
4. Attribute associated with the wrong entity type (relationship type)
5. Relationships are sets!
6. No partial participation in relationships!
7. Missing existence dependencies (use subclasses)
8. Invalid constraints
9. Using Subtypes for n:1 relationships; using relationships when
subtypes should be used.
10. When defining relationships: Too general entity types for participating
entities
11. Too many entity types
12. Using foreign keys instead of relationships
Other Issues in E/R Design
1. No relationships of relationships --- solution: create
an entity type that represent instances of the
relationship (or use aggregation as discussed in the
textbook)
2. value or entity type --- solution: choose entity type if
it helps expressing constraints; otherwise, use value-
type.
End of Chapter 2