3 DM

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 51

IT230 - Organization of Databases

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

Conceptual Data Model


a graphical model that captures the
characteristics of the entities being
represented and the relationships among
them
independent of :
how the database will be physically stored
the database model that will be used to
implement the database
the type of DBMS to be used
Data Modeling

Crows Foot & Chen


Notation
The crow's foot notation was
invented by Gordon Everest, who
originally used the term "inverted
arrow" but now just calls it a "fork".
For cardinality, a fork or crow's foot
intuitively indicates "many", by its
many "toes"

Data Modeling

Crows Foot & Chen


Notation
Chen Notation
Peter Chen invented entity/relationship modeling in
the mid-1970s and his approach remains widely
used today. It is unique in its representation of
relationships and attributes. Relationships are
shown with a separate diamond-shaped symbol
on the relationship line, and attributes are shown
in separate circles, instead of annotations on each
entity.

Data Modeling

Entity- Relationship Model


most commonly used conceptual
model
consists of:
entities
attributes of both the entities and
their relationships
relationships among entities
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 Type & Entity


Instance
Entity type
- a collection of
entities that
share common
properties or
characteristics
- also known as
entity class
Data Modeling

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

Entity & Attributes

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

must not change over time


- the value should not change over the life of
each entity instance
Data Modeling

Example of E-R Diagram

Data Modeling

Basic E-R Notation

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

Optional and Mandatory


Relationships
Optional Relationship
an instance of one entity may not be
associated with an instance of the related
entity
Mandatory Relationship
every instance in one entity type must be
associated with at least one instance in
the related entity

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

Optional and Mandatory


Cardinality
optional cardinality
- if minimum cardinality is 0
mandatory cardinality
- if minimum cardinality is 1
Mandatory 1
cardinality
Data Modeling

Optional and Mandatory


Cardinality
1-Many cardinality
Optional 0 or 1
cardinality
Optional 0-Many
cardinality
Data Modeling

Cardinality

Prentice Hall, 2002

30

Unary relationships -- figure 3-12a

Prentice Hall, 2002

31

Binary relationships figure 3-12b

Prentice Hall, 2002

32

Ternary relationships figure 3-12c

Note: a relationship can have attributes of its own


Prentice Hall, 2002

33

Basic relationship with only maximum cardinalities showing


figure 3-16a

Mandatory minimum cardinalities figure 3-17a

Prentice Hall, 2002

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

Figure 3-7 -- A composite attribute

An attribute
broken into
component parts

Prentice Hall, 2002

40

Figure 3-9a Simple key attribute

The key is underlined

Prentice Hall, 2002

41

Figure 3-9b -- Composite key attribute

The key is composed


of two subparts

Prentice Hall, 2002

42

Figure 3-8 -- Entity with a multivalued attribute (Skill) and


derived attribute (Years_Employed)
Whats wrong with this?

Multivalued:

Derived

an employee can have


more than one skill

from date employed and current date

Prentice Hall, 2002

43

Figure 3-19 an attribute that is both multivalued and composite

This is an
example of
time-stamping
Prentice Hall, 2002

44

Data Modeling

Data Modeling

Data Modeling

Mapping Entity

Data Modeling

Data Modeling

Relational Model Constraints

Data Modeling

Data Modeling

You might also like