Professional Documents
Culture Documents
birthday
id
Actor
name address
• Attributes
– Simple (Age)
– Composite (Address , Date of Joining)
– Single Valued (Age)
– Multi Valued (Car Type, Car Fuel Type, Car Color)
– Derived (Age from Date of Birth)
– Complex (Combination of Composite & multi values
attributes)
• An attribute takes a null value when an entity
does not have a value for it.
Degree of Relationship Type:
The degree of relationship type is the
number of participating entity types.
For eg,
WORKS_FOR relationship is of degree 2 called
binary.
SUPPLY is of degree 3 (supplier, parts, project)
• Constraints on Relationship Types:
Relationship Types usually have certain constraints that
limit the possible combinations of entities that may
participate in the corresponding relationship set.
–Mapping Cardinalities (Max. no. of relationship
instances an entity can participate)
• One to One
• One to many
• Many to One
• Many to Many
Participation Constraints
Specifies whether the existence of an entity
depends on another entity via relationship type.
The two types of participation constraints are:
• Total Participation (Existence dependency)
• Partial
– Keys
One-to-One
A film is directed by at most one director
A director can direct at most one film
id
Director Directed Film title
name
id
Director Directed Film title
name
id
Director Directed Film title
name
car1
((ABC 123, TEXAS), TK629, Ford Mustang, convertible, 1999, (red, black))
car2
((ABC 123, NEW YORK), WP9872, Nissan 300ZX, 2-door, 2002, (blue))
car3
((VSY 720, TEXAS), TD729, Buick LeSabre, 4-door, 2003, (white, blue))
.
.
.
SUMMARY OF ER-DIAGRAM
NOTATION FOR ER SCHEMAS
Symbol Meaning
ENTITY TYPE
RELATIONSHIP TYPE
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
COMPOSITE ATTRIBUTE
DERIVED ATTRIBUTE
E1 R E2 TOTAL PARTICIPATION OF E2 IN R
e1 r1 d1
e2 r2
e3 d2
r3
e4
r4
e5 d3
r5
e6
e7 r6
r7
Example relationship instances of the WORKS_ON relationship
between EMPLOYEE and PROJECT
r9
e1 r1 p1
e2 r2
e3 p2
r3
e4
r4
e5 p3
r5
e6
e7 r6
r7
r8
Relationships and Relationship Types (2)
• More than one relationship type can exist with the same
participating entity types. For example, MANAGES and
WORKS_FOR are distinct relationships between EMPLOYEE
and DEPARTMENT, but with different meanings and different
relationship instances.
ER DIAGRAM – Relationship Types are:
WORKS_FOR, MANAGES, WORKS_ON, CONTROLS,
SUPERVISION, DEPENDENTS_OF
Weak Entity Types
• An entity that does not have a key attribute
• A weak entity must participate in an identifying relationship type
with an owner or identifying entity type
• Entities are identified by the combination of:
– A partial key of the weak entity type
– The particular entity they are related to in the identifying
entity type
Example:
Suppose that a DEPENDENT entity is identified by the dependent’s
first name and birhtdate, and the specific EMPLOYEE that the
dependent is related to. DEPENDENT is a weak entity type with
EMPLOYEE as its identifying entity type via the identifying
relationship type DEPENDENT_OF
Weak Entity Type is: DEPENDENT
Identifying Relationship is: DEPENDENTS_OF
Constraints on Relationships
e1 r1 d1
e2 r2
e3 d2
r3
e4
r4
e5 d3
r5
e6
e7 r6
r7
Relationships and Relationship Types (3)
• We can also have a recursive relationship type.
• Both participations are same entity type in different roles.
• For example, SUPERVISION relationships between EMPLOYEE
(in role of supervisor or boss) and (another) EMPLOYEE (in
role of subordinate or worker).
• In following figure, first role participation labeled with 1 and
second role participation labeled with 2.
• In ER diagram, need to display role names to distinguish
participations.
A RECURSIVE RELATIONSHIP
SUPERVISION
EMPLOYEE SUPERVISION
e1 2
1 r1
e2 2
1 r2
e3 2
1 r3
e4
2
e5 1
1 r4
e6 2
1
r5
e7
2
r6
© The Benjamin/Cummings Publishing Company, Inc. 1994, Elmasri/Navathe, Fundamentals of Database Systems, Second Edition
Recursive Relationship Type is: SUPERVISION
(participation role names are shown)
Attributes of Relationship types
Examples:
l A department has exactly one manager and an employee can manage at
most one department.
– Specify (0,1) for participation of EMPLOYEE in MANAGES
l An employee can work for exactly one department but a department can
have any number of employees.
– Specify (1,1) for participation of EMPLOYEE in WORKS_FOR
(1,1) (1,N)
COMPANY ER Schema Diagram
using (min, max) notation
Relationships of Higher Degree
ENTITY TYPE
RELATIONSHIP TYPE
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
COMPOSITE ATTRIBUTE
DERIVED ATTRIBUTE
E1 R E2 TOTAL PARTICIPATION OF E2 IN R
(0,1) (1,1)
(1,1) (1,N)
COMPANY ER Schema Diagram
using (min, max) notation
Designing an ER Diagram
Consider the following set of requirements for a University database. Design an ER diagram
for this application:
• The university keeps track of each student's name, student number, social security
number, current address and phone number, permanent address and phone number,
birthdate, sex, class (freshman, graduate), major department, minor department (if
any), degree program (B.A., B.S., ... Ph.D.). Some user applications need to refer to the
city, state, and zip code of the student's permanent address and to the student's last
name. Both social security number and student number are unique for each student.
All students will have at least a major department.
• Each department is described by a name, department code, office number, office
phone, and college. Both the name and code have unique values for each department.
• Each course has a course name, description, course number, number of credits, level
and offering department. The course number is unique for each course.
• Each section has an instructor, semester, year, course, and section number. The section
number distinguishes sections of the same course that are taught during the same
semester/year; its value is an integer (1, 2, 3, ... up to the number of sections taught
during each semester).
• A grade report must be generated for each student that lists the section, letter grade,
and numeric grade (0,1,2,3, or 4) for each student and calculates his or her average
GPA.
University ER Diagram
Degree DName DCode OfficeNumber
Name StudentID SSN
Major In
Birth date
OfficePhone
Department
Sex Student
College
Class Minor In
Address
CName
Grade_Report
CourseDesc
Letter Grade Instructor Year Course
CNumber
GPA
Credits
Numeric Grade Section Belong_To
SectionNumber Semester
ER DIAGRAM FOR A BANK
DATABASE
© The Benjamin/Cummings Publishing Company, Inc. 1994, Elmasri/Navathe, Fundamentals of Database Systems, Second Edition
FIGURE 3.17
An ER diagram
for an AIRLINE
database
schema.
The Enhanced Entity-Relationship
(EER) Model
• Enhanced ER (EER) model
– Created to design more accurate database
schemas
• Reflect the data properties and constraints more
precisely
– More complex requirements than traditional
applications
Subclasses, Superclasses, and
Inheritance
• EER model includes all modeling concepts of
the ER model
• In addition, EER includes:
– Subclasses and superclasses
– Specialization and generalization
– Category or union type
– Attribute and relationship inheritance
Subclasses, Superclasses, and
Inheritance (cont’d.)
• Enhanced ER or EER diagrams
– Diagrammatic technique for displaying these
concepts in an EER schema
• Subtype or subclass of an entity type
– Subgroupings of entities that are meaningful
– Represented explicitly because of their
significance to the database application
Subclasses, Superclasses, and
Inheritance (cont’d.)
• Terms for relationship between a superclass
and any one of its subclasses
– Superclass/subclass
– Supertype/subtype
– Class/subclass relationship
• Type inheritance
– Subclass entity inherits all attributes and
relationships of superclass
Specialization and Generalization
• Specialization
– Process of defining a set of subclasses of an entity
type
– Defined on the basis of some distinguishing
characteristic of the entities in the superclass
• Subclass can define:
– Specific attributes
– Specific relationship types
Specialization and Generalization
(cont’d.)
• Certain attributes may apply to some but not
all entities of the superclass
• Some relationship types may be participated
in only by members of the subclass
Generalization
• Reverse process of abstraction
• Generalize into a single superclass
– Original entity types are special subclasses
• Generalization
– Process of defining a generalized entity type from
the given entity types
Constraints and Characteristics of
Specialization and Generalization
Hierarchies
• Constraints that apply to a single
specialization or a single generalization
• Differences between specialization/
generalization lattices and hierarchies
Constraints on Specialization and
Generalization
• May be several or one subclass
• Determine entity subtype:
– Predicate-defined (or condition-defined)
subclasses
– Attribute-defined specialization
– User-defined
Constraints on Specialization and
Generalization (cont’d.)
• Disjointness constraint
– Specifies that the subclasses of the specialization
must be disjoint
• Completeness (or totalness) constraint
– May be total or partial
• Disjointness and completeness constraints are
independent
Specialization and Generalization
Hierarchies
and Lattices
• Specialization hierarchy
– Every subclass participates as a subclass in only
one class/subclass relationship
– Results in a tree structure or strict hierarchy
• Specialization lattice
– Subclass can be a subclass in more than one
class/subclass relationship
Specialization and Generalization
Hierarchies
and Lattices (cont’d.)
• Multiple inheritance
– Subclass with more than one superclass
– If attribute (or relationship) originating in the
same superclass inherited more than once via
different paths in lattice
• Included only once in shared subclass
• Single inheritance
– Some models and languages limited to single
inheritance
Utilizing Specialization and
Generalization in Refining Conceptual
Schemas
• Specialization process
– Start with entity type then define subclasses by
successive specialization
– Top-down conceptual refinement process
• Bottom-up conceptual synthesis
– Involves generalization rather than specialization
Modeling of UNION Types Using
Categories
– Union type or a category
– Represents a single superclass/subclass
relationship with more than one superclass
– Subclass represents a collection of objects that is a
subset of the UNION of distinct entity types
– Attribute inheritance works more selectively
– Category can be total or partial
• Some modeling methodologies do not have
union types
A Sample UNIVERSITY EER Schema,
Design Choices, and Formal Definitions