slide content original, slide layout from database management systems 3ed, r. ramakrishnan and j....

9
ent original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J The Entity-Relationship Model Chapter 2

Upload: samuel-holt

Post on 13-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2

Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1

The Entity-Relationship Model

Chapter 2

Page 2: Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2

Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke2

Database Design Basics: Six Steps in Design

1. Data Requirements Analysis: a) what must be stored, b) how will it be used, and c) what actions occur most often.

2. Conceptual Database Design: Use ERD(s) to group data into entities and relationships.

3. Logical Database Design: Convert ERD(s) to conceptual schemas.

4. Schema Refinement: Eliminate redundancy and refine tables for performance.

5. Physical Database Design: Decide how to store and index the data.

6. Application and Security Design: Put the DB in the application’s context.

Page 3: Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2

Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke3

ER Model Basics

Employees

ssn

Works_In

Attribute (descriptive attribute), entities (relationships) possess these.

Entity. A group of these is an entity set.

Relationship ( if “ISA”). A group would be a relationship set.

ISA

Page 4: Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2

Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke4

ER Model Basics (Example)

class

office

phonename

name

declares MajorStudents

ssn

How do we choose a key?

Candidate keys and primary keys

Page 5: Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2

Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke5

ER Model Basics (Example)

class

office

phonename

name

declares MajorStudents

ssn

Two types of constraints to consider: key constraints and participation constratints.

Key constraints can be one-to-many or many-to-many

Participation constraints can be total or partial

Page 6: Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2

Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke6

ER Model Basics (Example)

class

office

phonename

name

declares MajorStudents

ssn

Total participation (all)

Total participation and key constraint (all and only one)

Key constraint (only one)

Page 7: Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2

Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke7

ER Model: Other Concepts: Weak Entity Sets

rank didname

name

sponsors dependentmember

ssn

These symbols must be “bolded”to denote the weak entity set

The link is “bolded” toshow total participation.It must also have anarrowhead to show a key constraint.

Page 8: Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2

Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke8

ER Model: Other Concepts: ISA Relationships

gender

name

employee

id

isa

faculty staff student

salary contract wage ins date wagedate

Two constraints ofconcern with ISArelationships:

* Overlap (no by default)

* Covering (no by default)

Page 9: Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2

Slide content original, slide layout from Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke9

ER Model: Other Concepts: Aggregation

phonename

addr

hires agentcustomer

nameorder

Prod #

buysproduct

name

quantity

price

Could also use aternary relationship