3 DM
3 DM
3 DM
Introduction
In designing databases, we begin by
examining the entities that are of
importance to an organization.
A conceptual data model is created
to capture the overall structure of
the entities and the relationships
among them
Data Modeling
Data Modeling
Data Modeling
Entity-Relationship Diagram
Data Modeling
Entity
an entity is a person,
place, thing, or event
about which an
organization wishes
to maintain data
examples:
students
subjects
instructors
Data Modeling
an entity is
represented by a
rectangle:
STUDENT
SUBJECT
Entity instance
- a single
occurrence of an
entity type
- an entity type
can have many
instances
Attributes
an attribute is a
characteristic of an
entity
examples:
Name
ID Number
Address
Birthday
are attributes of the
entity STUDENT
Data Modeling
an attribute is
represented by an
ellipse:
Name
ID_Num
STUDENT
Address
Birthday
Data Modeling
Value of an Attribute
the value of the type of characteristic
that an attribute represents
example:
attribute: Name
value: Carmen Santiago
the ERD contains only the attribute
type and not its value
Data Modeling
Multivalued Attributes
attributes having
more than one
value for each
entity instance
example:
hobby - a student
may have more
than 1 hobbies
Data Modeling
a multivalued
attribute is
represented by a
double ellipse:
Hobby
STUDENT
Identification of Entity
Instances
The relational model uses primary
keys to link related entities together.
Primary key - an attribute or a
combination of attributes that
uniquely identifies an occurrence of
an entity
represented by underlining the
ID_Num
attribute/s involved
Data Modeling
Characteristics of a
Primary Key
The value of a primary key must be:
unique
- no two entity instances can have the same
value for the primary key attribute
not null
- the value should be valid and not null
Data Modeling
Data Modeling
Relationship
a relationship is a
natural association
between the
instances of one or
more entities
example:
enrols - a student
enrols in a subject
relationships may
also have attributes
Data Modeling
a relationship is
represented by a
diamond-shaped
symbol:
STUDENT
enrols
SUBJECT
Types of Relationship
three possible types of relationship
can exist between the occurrences of
related entity types:
one to one relationship
one to many relationship
many to many relationship
Data Modeling
Data Modeling
Degree of a Relationship
the number of entity types that is
attached to a relationship
3 most common types:
unary relationship
binary relationship
ternary relationship
Data Modeling
Degree of relationships
One entity
related to
another of
the same
entity type
Prentice Hall, 2002
Entities of
two different
types related
to each other
22
Entities of three
different types
related to each
other
Unary Relationship
a recursive
relationship between
the instances of a
single entity
a relationship that
exists within one
relational table to
link related instances
of that entity
together
Data Modeling
PERSON
is
married
to
Binary Relationship
an association between two entity
types
most common type
STUDENT
Data Modeling
enrols
SUBJECT
Ternary Relationship
an association among three related
entity types
PART
VENDOR
Data Modeling
ships
WAREHOUSE
Gerund
also known as
composite entity
a many to many
relationship that is
modeled as an
entity type
Data Modeling
a gerund is
represented by:
shipment
Cardinality
the number of instances that is associated
between a pair of entity types
the cardinality of the association from A to
B is the maximum number of occurrences
of B that can be associated with A
a pair of associations can exist between
any two entities:
- from A to B and from B to A
Data Modeling
Cardinality
30
31
32
33
34
ISA Relationship
relationship between
a supertype and a
subclass subtype
the class contains
attributes common
to all subclasses but
each subclass
contains distinct
attributes
Data Modeling
represented by a
square with
rounded corners
STUDENT
ISA
UNDERGRAD
ISA
GRAD
Inheritance
each subtype inherits all the
attributes of the supertype
Name
ID_Num
Address
STUDENT
ID_Num
ISA
ISA
ID_Num
Course
Degree
UNDERGRAD
Data Modeling
GRAD
Attributes
Attribute - property or characteristic
of an entity type
Classifications of attributes:
Simple versus Composite Attribute
Single-Valued versus Multivalued
Attribute
Stored versus Derived Attributes
Identifier Attributes
Data Modeling
Identifiers (Keys)
Identifier (Key) - An attribute (or
combination of attributes) that
uniquely identifies individual
instances of an entity type
Simple Key versus Composite Key
Candidate Key an attribute that
could be a keysatisfies the
requirements for being a key
Data Modeling
Characteristics of Identifiers
Will not change in value
Will not be null
No intelligent identifiers (e.g.
containing locations or people that
might change)
Substitute new, simple keys for long,
composite keys
Data Modeling
An attribute
broken into
component parts
40
41
42
Multivalued:
Derived
43
This is an
example of
time-stamping
Prentice Hall, 2002
44
Data Modeling
Data Modeling
Data Modeling
Mapping Entity
Data Modeling
Data Modeling
Data Modeling
Data Modeling