ER Modeling
ER Modeling
Pradnya Mehta
ENTITY-RELATIONSHIP MODEL
Design Process
Modeling
Constraints
E-R Diagram
Design Issues
Weak Entity Sets
Extended E-R Features
Design of the Bank Database
Reduction to Relation Schemas
Database Design
UML
DESIGN PHASES
One to One to
one many
Note: Some elements in A and B may not be mapped
to any
elements in the other set
MAPPING CARDINALITIES
Many to Many to
one many
Note: Some elements in A and B may not be mapped
to any
elements in the other set
COMPLEX ATTRIBUTES
Attribute types:
▪ Simple and composite attributes.
▪ Single-valued and multivalued attributes
▪ Example: multivalued attribute: phone_numbers
▪ Derived attributes
▪ Can be computed from other attributes
▪ Example: age, given date_of_birth
Domain – the set of permitted values for each attribute
COMPOSITE ATTRIBUTES
REDUNDANT ATTRIBUTES
Suppose we have entity sets:
▪ instructor, with attributes: ID, name, dept_name, salary
▪ department, with attributes: dept_name, building, budget
We model the fact that each instructor has an
associated department using a relationship set
inst_dept
The attribute dept_name appears in both entity sets.
Since it is the primary key for the entity set
department, it replicates information present in the
relationship and is therefore redundant in the entity
set instructor and needs to be removed.
BUT: when converting back to tables, in some cases the
attribute gets reintroduced, as we will see later.
WEAK ENTITY SETS
Consider a section entity, which is uniquely identified by a
course_id, semester, year, and sec_id.
Clearly, section entities are related to course entities. Suppose
we create a relationship set sec_course between entity sets
section and course.
Note that the information in sec_course is redundant, since
section already has an attribute course_id, which identifies
the course with which the section is related.
One option to deal with this redundancy is to get rid of the
relationship sec_course; however, by doing so the
relationship between section and course becomes implicit in
an attribute, which is not desirable.
WEAK ENTITY SETS (CONT.)
An alternative way to deal with this redundancy is to not store
the attribute course_id in the section entity and to only
store the remaining attributes section_id, year, and
semester. However, the entity set section then does not
have enough attributes to identify a particular section
entity uniquely; although each section entity is distinct,
sections for different courses may share the same
section_id, year, and semester.
To deal with this problem, we treat the relationship sec_course
as a special relationship that provides extra information, in
this case, the course_id, required to identify section
entities uniquely.
The notion of weak entity set formalizes the above intuition. A
weak entity set is one whose existence is dependent on
another entity, called its identifying entity; instead of
associating a primary key with a weak entity, we use the
identifying entity, along with extra attributes called
discriminator to uniquely identify a weak entity. An entity
set that is not a weak entity set is termed a strong entity
set.
WEAK ENTITY SETS (CONT.)
Every weak entity must be associated with an identifying
entity; that is, the weak entity set is said to be
existence dependent on the identifying entity set.
The identifying entity set is said to own the weak
entity set that it identifies. The relationship
associating the weak entity set with the identifying
entity set is called the identifying relationship.
Note that the relational schema we eventually create
from the entity set section does have the attribute
course_id, for reasons that will become clear later,
even though we have dropped the attribute course_id
from the entity set section.
E-R DIAGRAMS
ENTITY SETS
schema attributes
person ID, name, street, city
student ID, tot_cred
employee getting information
▪ Drawback: ID, salary
about, an employee requires
accessing two relations, the one corresponding to the low-level
schema and the one corresponding to the high-level schema
REPRESENTING SPECIALIZATION AS SCHEMAS
(CONT.)
Method 2:
▪ Form a schema for each entity set with all local and inherited
attributes
schema attributes
person ID, name, street, city
student ID, name, street, city, tot_cred
employee ID, name, street, city, salary