Copyright (c) 2014 Pearson Education, Inc. Introduction to Databases.
-
Upload
lisa-nichols -
Category
Documents
-
view
217 -
download
3
Transcript of Copyright (c) 2014 Pearson Education, Inc. Introduction to Databases.
Copyright (c) 2014 Pearson Education, Inc.
Introduction to Databases
Copyright (c) 2014 Pearson Education, Inc.
INTRODUCTION
Entity-relationship (ER) modeling - conceptual database modeling technique • Enables the structuring and organizing of the requirements
collection process • Provides a way to graphically represent the requirements
ER diagram (ERD) - the result of ER modeling • Serves as a blueprint for the database
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 2
Copyright (c) 2014 Pearson Education, Inc.
ENTITIES
Entities - constructs that represent what the database keeps track of• The basic building blocks of an ER diagram• Represent various real world notions, such as people,
places, objects, events, items, and other concepts• Within one ERD each entity must have a different name
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 3
Copyright (c) 2014 Pearson Education, Inc.
ENTITIES
Two entities
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 4
Copyright (c) 2014 Pearson Education, Inc.
ENTITIES
Entity instances (entity members) - occurrences of an entity• Entities themselves are depicted in the ER diagrams while
entity instances are not• Entity instances are eventually recorded in the database
that is created based on the ER diagram
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 5
Copyright (c) 2014 Pearson Education, Inc.
ATTRIBUTES
Attribute - depiction of a characteristic of an entity• Represents the details that will be recorded for each entity
instance• Within one entity, each attribute must have a different
name
Unique Attribute - attribute whose value is different for each entity instance• Every regular entity must have at least one unique attribute
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 6
Copyright (c) 2014 Pearson Education, Inc.
ATTRIBUTES
An entity with attributes
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 7
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
Relationship - ER modeling construct depicting how entities are related• Within an ER diagram, each entity must be related to at
least one other entity via a relationship
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 8
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
Cardinality constraints - depict how many instances of one entity can be associated with instances of another entity• Maximum cardinality
o One (represented by a straight bar: I) o Many (represented by a crow’s foot symbol)
• Minimum cardinality (participation)o Optional (represented by a circular symbol: 0) o Mandatory (represented by a straight bar: I)
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 9
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
A relationship between two entities
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 10
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
Four possible cardinality constraints
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 11
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
Several possible versions of the relationship ReportsTo
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 12
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
Types of Relationships (maximum cardinality-wise)• One-to-one relationship (1:1)• One-to-many relationship (1:M)• Many-to-many relationship (M:N)
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 13
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
Three types of relationships (maximum cardinality-wise)
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 14
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
A 1:M Relationship
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 15
A M:N Relationship
A 1:1 Relationship
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
Relationship instances - occurrences of a relationship• Occur when an instance of one entity is related to an
instance of another entity via a relationship• Relationship themselves are depicted in the ER diagrams
while relationship instances are not• Relationship instances are eventually recorded in the
database that is created based on the ER diagram
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 16
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
A relationship and its instances
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 17
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
Relationship attributes • In some cases M:N relationships can actually have attributes
of their own
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 18
Copyright (c) 2014 Pearson Education, Inc.
TERNARY RELATIONSHIP
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 19
Copyright (c) 2014 Pearson Education, Inc.
RELATIONSHIPS
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 20
Relationship attributes Example
Copyright (c) 2014 Pearson Education, Inc.
ATTRIBUTES
Composite attribute – attribute that is composed of several attributes• Not an additional attribute of an entity• Its purpose is to indicate a situation in which a collection of
attributes has an additional meaning, besides the individual meanings of each attribute
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 21
Copyright (c) 2014 Pearson Education, Inc.
ATTRIBUTES
An entity with a composite attribute
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 22
Copyright (c) 2014 Pearson Education, Inc.
ATTRIBUTES
Composite unique attribute – attribute that is composed of several attributes and whose value is different for each entity instance
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 23
Copyright (c) 2014 Pearson Education, Inc.
ATTRIBUTES
An entity with a unique composite attribute
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 24
Copyright (c) 2014 Pearson Education, Inc.
ATTRIBUTES
Multiple unique attributes (candidate keys) - when an entity has more than one unique attribute each unique attribute is also called a candidate key
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 25
Copyright (c) 2014 Pearson Education, Inc.
ATTRIBUTES
An entity with multiple unique attributes (candidate keys)
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 26
Copyright (c) 2014 Pearson Education, Inc.
Task from E-book:
What is a weak entity? Provide an example.
Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 27