Data Modeling and Relational Database Design. Analyze and model the relationships between entities Draw an initial entity relationship diagram Read the.

Post on 25-Dec-2015

214 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

Modeling RelationshipsData Modeling and Relational Database Design

Objectives

Analyze and model the relationships between entities

Draw an initial entity relationship diagram

Read the relationships on an ER diagram

Clearly define relationship names

Relationship Definitions

The way one entity relates to another

The business rules that link together business information needs

What one thing has to do with another

A named association between entities

Bi-directional Relationships

DMDD COURSE SMT COURSESMT COURSE

INSTRUCTOR COURSE

Diagramming Conventions

A line between two entities

Lower case relationship name

Optionality (Minimum cardinality)

Degree (Maximum cardinality)

Optional - may beMandatory - must be

One or more

One and only one

Diagramming Conventions

COPY TITLE

many(crow’s foot)

mandatory

optional

one

Relationship Syntax

Each

Subject entity

must beormay be

relationshipname

one or moreorone and only one

entity 1 entity 2

DegreeObject entityOptionality Name

Validation - in class practice

EMPLOYEE DEPARTMENTassigned to

Validation - in class solution

EMPLOYEE DEPARTMENTassigned to

Each EMPLOYEE must be assigned to one and only one DEPARTMENT

Validation - in class practice

EMPLOYEE DEPARTMENT

responsible for

Validation - in class solution

EMPLOYEE DEPARTMENT

Each DEPARTMENT may be responsible for one or more EMPLOYEES

responsible for

EMPLOYEE DEPARTMENTassigned to

Each EMPLOYEE must be assigned to one and only one DEPARTMENT

EMPLOYEE DEPARTMENT

Each DEPARTMENT may be responsible for one or more EMPLOYEES

responsible for

Validation - in class solution

Validation - in class practice

taken by

enrolled inSTUDENT COURSE

Validation - in class solution

Each STUDENT may be enrolled in one or more COURSES

Each COURSE may be taken by one or more STUDENTS

taken by

enrolled inSTUDENT COURSE

Relationship Types

Many-to-One

One-to-One

Many-to-Many

Many-to-One Relationships

CUSTOMER SALES REPRESENTATIVE

assigned to

visited by

Many-to-Many Relationships

PATIENT HEALTH CARE WORKER

assigned to

attended by

One-to-One Relationships

BICYCLE CYCLIST

the rider of

is ridden by

Represents a snapshot in time

Analyzing & Modeling Relationships

1 Determine the existence of a relationship

2 Name each direction of the relationship

3 Determine the degree of each direction of the relationship

4 Determine the optionality of each direction of the relationship

5 Read the relationship aloud to validate it

Determining a Relationship’s ExistenceExistenceName

OptionalityDegree

Validate

MEMBERSHIP COPY

COPY

RENTAL

RENTAL

MEMBERSHIP

RENTAL

MEMBERSHIP

COPY

Naming the RelationshipExistenceName

OptionalityDegree

Validate

COPY TITLEof

available as

Each title is available as a copy and each copy is of a title

Determining the Degree

Name

OptionalityDegree

Validate

Existence

COPY TITLE

one

many

Each title is available as a copy, there could be lots of copies but there is only ever one title on a copy

Determining the OptionalityExistenceName

OptionalityDegree

Validate

optional

mandatory

COPY TITLE

Every copy must have a title on it but we needinformation about titles even if there is no copy

Validating the Relationship

ExistenceName

OptionalityDegree

Validate

COPY TITLEof

available as

Each copy must be of one and only one title, and each title may be available as one or more copies

Summary

Establish the existence of a relationship

Name the relationship

Determine its degree

Determine its optionality

Read the relationship to validate it

top related