Chapter 4 Session1
Chapter 4 Session1
Chapter 4 Session1
High-Level
Database Model
Relational
Getting
High-Level Database Relational
User
Design Schema DBMS
Requirement
Design
Logical design:
We must choose a DBMS to implement our database
design, and map the high level conceptual data model in
the previous phase onto a logical data model of the
chosen DBMS (relational, network, hierarchical, object-
oriented)
We will only consider relational DBMS
Convert an ER diagram from the conceptual model
into a relational schemas in normal form using
Normalization.
◦ Normalization is used to check the entity relationship model
and help eliminate redundancy and other anomalies in the
database.
Low level design
Physical design:
Describes how the database is to be implemented:
◦ Creating a set of relational tables and the constraints on
these tables from the information presented in the
logical data model;
◦ Identifying the specific storage structures and access
methods for the data to achieve an optimum
performance for the database system;
◦ Designing security protection for the system.
Entity Relationship Model
ERM is a high level data model used for developing the
conceptual design of the database.
The ER model also has an associated diagrammatic
representation, the ER diagram, which can express the
overall logical structure of a database graphically
Many various notations used with ERD—the original
Chen notation and the newer Crow’s Foot and UML
notations.
The Chen notation favors conceptual modeling.
The Crow’s Foot notation favors a more implementation-oriented
approach
The UML notation can be used for both conceptual and
implementation modeling.
13
Entity Relationship Model
14
Entity
An entity is a person, a place, an object, an event, or a
concept in the user environment about which the
organization wishes to maintain data.
An entity has a noun name.
Example:
◦ Person: Student, teacher, employee, author,..
◦ Place: store, classroom, warehouse,…
◦ Object: Movie, product, car, book,..
◦ Event: Sale, Registration, Reservation
◦ Concept: Account, Course
15
Entity
An entity type (or entity set) is a collection of entities
that share the common properties, or characteristics.
Example: the entity type student might represent the set of all
students in the university.
16
Entity
Example: Entity type versus Entity instance
17
Entity
There are two types of entities; weak and strong entity types.
A strong entity type is one that exists independently of other entity
types.
◦ Instances of a strong entity type always have a unique characteristic (called
an identifier)—that is, an attribute or a combination of attributes that
uniquely distinguish
each occurrence of that entity.
A weak entity type is an entity type whose existence depends on
some other entity type
◦ The entity type on which the weak entity type depends is called the
identifying owner
◦ A weak entity type does not typically have its own identifier
18
Entity
Example: Weak entity in ERD
Carries relationship is the identifying relationship
(indicated by the double line)
The attribute Dependent Name serves as a partial
identifier (indicated by double underline)
19
Attribute
20
Attribute
21
Identifier Attribute
Attribute types:
Identifier Attribute
Required and Optional attribute
Simple and Composite attribute
Single-valued and Multivalued attribute
Stored and Derived attribute
22
Identifier Attribute
23
Identifier Attribute
24
Identifier Attribute
25
Null values
26
Simple & Composite Attribute
27
Simple & Composite Attribute
Simple Attribute
Attribute that have not been divided into subparts
Simple (Atomic) attributes
◦ Ex: Age, City, Postal Code
Composite Attributes
Can be divided into smaller subparts, which
represent more basic attributes with independent
meaning.
◦ Ex: Name can broken down into component attributes:
first_name, middle_initial, last_name
28
Simple & Composite Attributes
Composite attributes
Example: name, address
29
Simple & Composite Attributes
Composite attributes
Most drawing tools do not have a notation for composite
attributes, so you simply list all the component parts
30
Single valued & Multivalued
Attributes
Single Valued Attributes
Can only have one value for the particular entity.
Ex: A student can have only one ID number
Multivalued Attributes
Attributes that can have many values
Ex: A student can have more than one phone number, one skill
Multivalued and composite are different concepts.
A multivalued attribute, may occur multiple times
for each employee
Composite attributes, each of which occurs once for each employee, but which
have component, more atomic attributes
31
Single valued & Multivalued
Attributes
Multivalued Attributes
Other E-R diagramming tools may use an asterisk (*)
after the attribute name, or
you may have to use supplemental documentation to
specify a multivalued attribute
32
Stored & Derived Attributes
Stored Attributes
The date_of_birth is the stored attribute
Derived attributes
Can be computed from other attributes
Example: age is derived from date_of_birth.
Age is called derived attribute
33
Example
E-R diagram with identifier, multivalued, and
derived attributes
34
Relationship
A relationship is an association among several
entities
A relationship set is a set of relationships of the
same type.
A relationship has a verb phrase name
Two entities can have more than one type of
relationship between them (multiple relationships)
35
Relationship
Relationship type and relationship instance
A relationship type is a meaningful association
between (or among) entity types
◦ The relationship type is modeled as lines between entity
types
A relationship instance is an association between entity
instances
36
Example Relationship type and
Relationship instances
a) Relationship type
b) Relationship instances
37
Relationship
Attributes on relationship
Relationships can have attributes which describe features
pertaining to the association between the entities in the
relationship
Example: Date Completed is a property of the relationship
Completes, rather than a property of either Employee or
Course entity.
38
Relationship
Associative Entity
Associative entity is an entity type that associates
the instances of one or more entity types and contains
attributes that are peculiar to the relationship between
those entity instances.
Associative entities are sometimes referred to as gerunds,
because the relationship name (a verb) is usually converted
to an entity name that is a noun.
39
Relationship
Associative Entity
Example: An associative entity Certificate
◦ Note that there are no relationship names on the lines between an associative
entity and a strong entity
An associative entity Certificate using Visio
40
Degree of a Relationship set
The degree of the relationship set is the number of entity
types that participate in a relationship.
Unary relationship, are also called Recursive relationship,
which exists when association is maintained within a single entit
(degree 1)
Binary relationship: exists when two entities are associated
(degree 2)
◦ Most relationship sets in a database system are binary.
Ternary relationship: exists when three entities are associated
(degree 3)
Relationships between more than three-entity types are rare
41
Degree of a Relationship set
43
Cardinality constraints
One to
one
One to
many
Many to
many
Minimum Cardinality
is the minimum number of instances of entity B that
may be associated with each instance of entity A
Maximum Cardinality
is the maximum number of instances of entity B that
may be associated with each instance of entity A
Ex:
47
Example of Cardinality
constraints
One-to-One relationship
one department chair—a professor—can chair only
one department, and one department can have only
one department chair.
One-to-Many relationship
Each painting is painted by one and only one painter,
but each painter could have many paintings.
48
Example of Mapping Cardinalities
Many-to-Many relationship
Each CLASS can have many STUDENTs, and each
STUDENT can take many CLASSES.
49
Optional and Mandatory
Participation
Participation determines whether all or only some
entity occurrences participate in a relationship.
Participation in a relationship can be optional (or
Partial) or mandatory (or Total) participation.
Mandatory participation:
◦ all entity occurrences are involved in a particular
relationship.
◦ Minimum cardinality is one
Optional participation:
◦ only some entities may not participate in a particular
relationship.
◦ Minimum cardinality is zero
50
Optional and Mandatory
Participation
Ex1:
51
Optional and Mandatory
Participation
Ex2:
52
Optional and Mandatory
Participation
Ex2:
A person is
married to at most
one other person,
or may not be
married at all
53
Optional and Mandatory
Participation
Another examples
An optional CLASS entity in the relationship “PROFESSOR teaches CLASS”:
54
Optional and Mandatory
Participation
Example: Identifying relationship, cardinality between
entities:
4. Customer and Order
5. Product and Category
6. Employee and Dependent
7. Employee and Department
8. Instructor and Class
Multiple Relationships Between
Entity Types
There may be more than one relationship between the
same entity types in a given organization
Ex: Employees and departments
One relationship associates employees with the
department in which they work.
The second relationship associates each department with
the employee who manages that department.
56
Weak Entity
57
Weak Entity
Example
58
Constructing an ER model
60
Exercises
Ex1: Company organized into DEPARTMENT.
An university has several departments. Each department
employs many employees, but each employee works in one
department only.
An employee can supervise many other employees, but an
employee may have only one supervisor.
Each department offers many courses. A course can be a pre-
requisite of many other courses, but a course may have only
one pre-requisite.
Exercises
Ex2: Company organized into DEPARTMENT.
Each department has unique name and a particular employee who
manages the department. Start date for the manager is recorded.
Department may have several locations.
A department controls a number of PROJECT. Projects have a unique
name, number and a single location.
Company’s EMPLOYEE name, ssno, address, salary, sex and birth
date are recorded. An employee is assigned to one department, but may
work for several projects (not necessarily controlled by her dept).
Number of hours/week an employee works on each project is recorded;
The immediate supervisor for the employee.
Employee’s DEPENDENT are tracked for health insurance purposes
(dependent name, birthdate, relationship to employee).
The Enhanced Entity Relationship
Model (EERM)
The term enhanced entity relationship (EER) model (or the
Extended entity relationship model) is used to identify the
model that has resulted from extending the original E-R model
with these new modeling constructs.
A Diagram using this model is called an EER diagram (EERD)
The most important modeling construct incorporated in the EER
model is supertype/subtype relationships
discriminator
63
The Enhanced Entity Relationship
Model (EERM)
An entity supertype is a generic entity type that is
related to one or more entity subtypes.
The entity supertype contains common
characteristics, and the entity subtypes each contain
their own unique characteristics.
64
Supertype/Subtype relationship
65
Supertype/Subtype relationship
66
Supertype/Subtype relationship
67
Example: Supertype/subtype relationships in
a hospital
68
Generalization and Specialization
Generalization:
The process of defining a more general entity type from a set of more
specialized entity types.
BOTTOM-UP process
Based on grouping common characteristics and relationships of the
subtypes
Specialization:
The process of defining one or more subtypes of the supertype and forming
supertype/subtype relationships.
TOP-DOWN process
Based on grouping unique characteristics and relationships of the subtypes
69
Example of generalization
So we put the
shared attributes
in a supertype
Only applies to
manufactured parts
72
Example of specialization (cont.)
b) Specialization to MANUFACTURED PART and PURCHASED PART
Created 2 subtypes
74
Examples of completeness constraints
a) Total specialization rule
A patient must be
either an outpatient or
a resident patient
75
Examples of completeness constraints (cont.)
b) Partial specialization rule
A vehicle
could be a
car, a truck,
or neither
76
Subtype Discriminator
77
Disjoint and Overlapping
Constraints
Disjoint subtypes
Also called nonoverlapping subtypes
Subtypes that contain unique subset of supertype entity set, in
other words, each entity instance of the supertype can appear in
only one of the subtypes
In an ERD, disjoint subtypes are indicated by the letter d inside
the category shape
Overlapping subtypes
Subtypes that contain nonunique subsets of supertype entity set,
that is, each entity instance of the supertype may appear in more
than one subtype.
In an ERD, illustrates overlapping subtypes with the letter o inside
the category shape.
78
Example: a subtype discriminator
(disjoint rule)
Employee_Type is called
the subtype discriminator
Example: Subtype discriminator (overlap rule)
80
Example: Subtype discriminator
(overlap rule)
A new attribute named Part Type has been added
to PART. Part Type is a composite attribute with
components Manufactured? and Purchased?
Each of these attributes is a Boolean variable (i.e.,
it takes on only the values yes, “Y,” and no, “N”).
When a new instance is added to PART, these
components are coded as follows:
81
Example of supertype/subtype hierarchy
82
Entity Clusters
83
Possible entity
clusters for Pine
Valley Furniture
in Microsoft
Visio
Related
groups of
entities
could
become
clusters
84
EER diagram of PVF entity clusters
More readable,
isn’t it?
85
Manufacturing entity cluster