CHAPTER 2 - Database Requirements and ER...

27
Copyright (c) 2016 Nenad Jukic and Prospect Press CHAPTER 2 - Database Requirements and ER Modeling Database Systems - Introduction to Databases and Data Warehouses

Transcript of CHAPTER 2 - Database Requirements and ER...

Page 1: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

CHAPTER 2 - Database Requirements and ER Modeling

Database Systems - Introduction to Databases and Data Warehouses

Page 2: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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

Page 3: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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

Presenter
Presentation Notes
An ER diagram for a retail company may contain entities, such as CUSTOMER, STORE, PRODUCT and SALES TRANSACTION.
Page 4: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

ENTITIES

Two entities

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 4

Page 5: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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

Presenter
Presentation Notes
Each depicted entity contains a number of entity instances or entity members. For example entity CUSTOMER may contain entity instances such as customer Joe, customer Sue, and customer Pat.
Page 6: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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

Page 7: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

ATTRIBUTES

An entity with attributes

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 7

Presenter
Presentation Notes
This example is discussed on Page 14.
Page 8: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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

Page 9: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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

Page 10: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

RELATIONSHIPS

A relationship between two entities

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 10

Presenter
Presentation Notes
The requirements for the relationship ReportsTo and the rules for interpreting cardinality constraints are given on Pages 14-15.
Page 11: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

RELATIONSHIPS

Four possible cardinality constraints

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 11

Page 12: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

RELATIONSHIPS

Several possible versions of the relationship ReportsTo

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 12

Presenter
Presentation Notes
The requirements for each of the versions shown are given on Pages 16-17.
Page 13: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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

Presenter
Presentation Notes
The maximum cardinality on either side of the relationship can be either one or many.
Page 14: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

RELATIONSHIPS

Three types of relationships (maximum cardinality-wise)

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 14

Page 15: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

RELATIONSHIPS

A 1:M Relationship

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 15

A M:N Relationship

A 1:1 Relationship

Presenter
Presentation Notes
The requirements for the three relationships (IsLocatedIn, AssignedTo, IsAlloted) are given on Page 18.
Page 16: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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

Page 17: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

RELATIONSHIPS

A relationship and its instances

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 17

Presenter
Presentation Notes
Illustrated relationship instances reflect the cardinality constraint symbols of the relationship.
Page 18: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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

Presenter
Presentation Notes
An attribute of a 1:M relationship or a 1:1 relationship is not necessary.
Page 19: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

RELATIONSHIPS

A M:N relationship with an attribute

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 19

Presenter
Presentation Notes
The requirements for the ER diagram shown are given on Page 19.
Page 20: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

RELATIONSHIPS

A 1:M relationship with and without an attribute

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 20

Presenter
Presentation Notes
The requirements and the discussion of the two ER diagrams shown here are given on Page 20.
Page 21: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 21

ER diagram example: ZAGI Retail Company Sales Department Database

Presenter
Presentation Notes
ZAGI Retail Company Sales Department Database requirements are given on Page 21. The knowledge of ER notation helps database requirements collectors gather structured and useful requirements for the future database. Knowing that an ER diagram has to be developed upon the completion of the database requirements process helps database requirements collectors focus on asking the right questions. Examples of such questions are given on Page 22.
Page 22: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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 22

Page 23: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

ATTRIBUTES

An entity with a composite attribute

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 23

Presenter
Presentation Notes
This example is discussed on Page 22.
Page 24: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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 24

Page 25: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

ATTRIBUTES

An entity with a unique composite attribute

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 25

Presenter
Presentation Notes
This example is discussed on Pages 23-24.
Page 26: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

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 26

Presenter
Presentation Notes
The term “candidate key” comes from the fact that a candidate key is a “candidate” to be chosen as the primary identifier (also known as a primary key) when implementing the resulting database. One of the candidate keys is chosen later as the “primary key” for the table corresponding to the entity that contains the candidate keys. Primary keys are discussed in Chapter 3.
Page 27: CHAPTER 2 - Database Requirements and ER Modelingmercury.pr.erau.edu/~siewerts/cs317/documents/... · Database Systems . Chapter 2 – Slide 26 . The term “candidate key” comes

Copyright (c) 2016 Nenad Jukic and Prospect Press

ATTRIBUTES

An entity with multiple unique attributes (candidate keys)

Jukić, Vrbsky, Nestorov – Database Systems Chapter 2 – Slide 27

Presenter
Presentation Notes
This example is discussed on Page 24.