0% found this document useful (0 votes)
15 views

DB 2

The document provides an overview of conceptual data modeling and entity-relationship diagrams (ERDs). It discusses key concepts such as entities, attributes, relationships, cardinalities, weak/strong entities, subtypes and supertypes. The goal of an ERD is to capture the structure and relationships between important entities for an organization, independent of physical storage or implementation details. ERDs use graphical symbols like rectangles, diamonds and ellipses to represent entities, relationships, and attributes.

Uploaded by

obiwan xeon
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

DB 2

The document provides an overview of conceptual data modeling and entity-relationship diagrams (ERDs). It discusses key concepts such as entities, attributes, relationships, cardinalities, weak/strong entities, subtypes and supertypes. The goal of an ERD is to capture the structure and relationships between important entities for an organization, independent of physical storage or implementation details. ERDs use graphical symbols like rectangles, diamonds and ellipses to represent entities, relationships, and attributes.

Uploaded by

obiwan xeon
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 53

1: Database Systems

Part II: Data Modeling

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

Conceptual Data Model

A graphical model showing the


following

Characteristics of the entities


Relationships among the entities

Independent of :

How the database will be physically stored


The data model used to implement the
database
The type of DBMS to be used
3

Entity-Relationship Diagram (ERD)

Most commonly used conceptual


model
Consists of:

Entities
Relationships among entities
Attributes of both the entities and their
relationships

Entity

An entity is a
person, place, thing,
or event which an
organization wishes
to maintain data
about
Examples:

Student
Subject
Instructor

An entity is
represented by a
rectangle

STUDENT

SUBJECT

Entity Type vs. Entity Instance

Entity type

A collection of all occurrences of a given


type of entity
Also known as entity class

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
Sample attributes
of the STUDENT
entity

Name
ID Number
Address
Birthday

An attribute is
represented by an
ellipse

Name

ID_Num

STUDENT

Address

Birthday
7

Value of an Attribute

The value of the type of characteristic


that an attribute represents
Example:

Attribute: Name
Values:

Fox Mulder
Dana Scully

The ERD contains only the attribute


type and not its values
8

Comparison of Attribute Types

Multivalued vs. single-valued


Composite vs. simple (or atomic)
Derived vs. stored

Multivalued Attributes

Attributes having
more than one
value for each
entity instance
Example:

Hobby - a student
may have more
than one hobbies

A multivalued
attribute is
represented by a
double ellipse
Hobby
STUDENT

10

Composite Attributes

An attribute
broken into
component parts

11

Example: An Attribute Both


Multivalued and Composite

12

Derived Attribute

An attributes whose values can be


calculated from related attribute values

Derived
from date employed and
current date

13

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 instance of an entity
Represented by underlining the
attribute(s) involved
ID_Num
14

Characteristics of a Primary Key

Unique - no two entity instances can


have the same value for the primary
key attribute
Not null
Must not change over time
Avoid use of intelligent keys
Substitute new, simple keys for long,
composite keys
15

Relationship

A relationship is a
natural association
between the
instances of one or
more entities
Example:

enrolls - a student
enrolls in a subject

A relationship is
represented by a
diamond-shaped
symbol

STUDENT

enrolls

SUBJECT

Relationships may
also have attributes
16

Degree of a Relationship

The number of entity types attached to


a relationship
Three (3) most common types

Unary relationship
Binary relationship
Ternary relationship

17

Unary Relationship

A recursive
relationship within
a single entity
Exists within an
entity to link related
instances of that
entity together

PERSON

is
married
to

18

Binary Relationship

An association between two entity


types
Most common relationship

STUDENT

enrolls

SUBJECT

19

Ternary Relationship

An association among three related


entity types
PART

VENDOR

ships

WAREHOUSE

20

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

21

Types of Relationship

Three (3) 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

22

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:

Ex. from A to B and from B to A


23

Examples of Cardinality

24

Example Instance Association in a


One-to-One Unary Relationship

25

Example Instance Association in a


Many-to-Many Relationship

26

Optional and Mandatory


Cardinality

Optional cardinality

Mandatory cardinality

If minimum cardinality is 0
If minimum cardinality is 1

Mandatory 1
cardinality
27

Optional and Mandatory


Cardinality

Mandatory 1-Many
cardinality

Optional 0 or 1
cardinality

Optional 0-Many
cardinality
28

Maximum Cardinality Constraints

Here, maximum
cardinality
constraint is 4
29

Multiple Relationships

Entities can be related to one another


in more than one way

30

Strong vs. Weak Entities, and


Identifying Relationships

Strong entities

Weak entity

Exist independently of other types of entities


Has its own unique identifier
Represented with single-line rectangle
Dependent on a strong entitycannot exist on its own;
has no business meaning in the ERD without the entity
(called identifying owner) it depends on
Does not have a unique identifier, only partial identifier
Represented with double-line rectangle

Identifying relationship

Links strong entities to weak entities


Represented with double line diamond
31

Example of Strong and Weak


Entities

Strong entity

Identifying relationship

Weak entity

32

Associative Entities (Gerund)

Also known as
composite entity
A many-to-many
relationship modeled as
an entity type
It is a relationship (but
would want to maintain
data about)
It is an entity in disguise
Has independent
meaning to end-users
and preferably
identifiable by a single
attribute

A gerund is
represented by a
diamond within a
rectangle

SHIPMENT

33

Associative Entity Example


Emp #

Name

EMP

Emp #

completes

Name

EMP

Date Completed

Date Completed

CERTIFICATE

Course ID

Title

COURSE

Course ID

Title

COURSE

Certificate #
34

Associative Entity Example

35

Associative Entity Example

36

Supertypes and Subtypes

Subtype: A subgroup an entity type which


has attributes that are distinct from those in
other subgroups
Supertype: An generic entity type that has a
relationship with one or more subtypes
Inheritance

Subtype entities inherit values of all attributes of


the supertype
An instance of a subtype is also an instance of
the supertype
37

Basic Notation

38

Relationships and Subtypes

Relationships at the supertype level


indicate that all subtypes will
participate in the relationship
The instances of a subtype may
participate in a relationship unique to
that subtype. In this situation, the
relationship is shown at the subtype
level
39

Example: Supertypes and Subtypes

40

Generalization & Specialization

Generalization

The process of defining a more general


entity type from a set of more specialized
entity type (bottom-up)

Specialization

The process of defining one or more


subtypes of the supertype and forming
supertype/subtype relationships (topdown)
41

Completeness Constraints

Whether an instance of a supertype


must also be a member of at least one
subtype

Total Specialization Rule: Yes (double


line)
Partial Specialization Rule: No (single
line)

42

Total Specialization Rule

A patient must be either


an outpatient or a
resident patient

43

Partial Specialization Rule

A vehicle could be a
car, a truck, or neither

44

Disjointness Constraints

Whether an instance of a supertype


may simultaneously be a member of
two (or more) subtypes
Disjoint Rule: An instance of the
supertype can be only ONE of the
subtypes
Overlap Rule: An instance of the
supertype could be more than one of
the subtypes
45

Disjointness Constraints

A patient can either be outpatient


or resident, but not both

46

Overlap Constraints

A part may be
both purchased
and manufactured

47

Constraints in Supertype/Subtype
Discriminators

Subtype Discriminator: An attribute of the


supertype whose values determine the
target subtype(s)
Two types:

Disjoint a simple attribute with alternative


values to indicate the possible subtypes
Overlapping a composite attribute whose
subparts pertain to different subtypes; each
subpart contains a boolean value to indicate
whether the instance belongs to associated
subtype
48

Discriminator: Disjoint Rule

A simple attribute
with different
possible values
indicating the subtype

49

Discriminator: Overlap Rule

A composite attribute
with sub-attributes
indicating yes or
no to determine
whether it is of each
subtype

50

Supertype/Subtype Hierarchy

51

Entity
Clusters

52

Inappropriate Diagrams

ERDs must not:

System user

System output

contain a user of
the system
contain an output
of the database
system (e.g. a
report)
be confused with
a user view
53

You might also like