Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Database Design

Resolving Many-to-Many Relationships

Copyright 2013, Oracle and/or its affiliates. All rights


reserved.

Resolving Many-to-Many Relationships

Objectives
This lesson covers the following objectives:
Identify attributes which belong to many-to-many
relationships
Demonstrate the steps to resolve a many-to-many
relationship using an intersection entity
Identify the UID of an intersection entity and represent it
in the entity relationship diagram

Copyright 2013, Oracle and/or its affiliates. All rights


reserved.

Resolving Many-to-Many Relationships

Purpose
This lesson will help you complete your model -- you may
need to create new entities or new relationships based on
the business needs.
It will also help you define the scope of your data model -you only model what is of importance to the business.

Copyright 2013, Oracle and/or its affiliates. All rights


reserved.

Resolving Many-to-Many Relationships

Relationship Hiding an Attribute


EVENT and PARTNER

In the DJ business, each


PARTNER may be
assigned to work on one
or more EVENTs. Each
EVENT may be a job for
one or more PARTNERs.

PARTNER
# id
* first name
* last name

EVENT PLANNER
* expertise

DJ
* specialty

MANAGER
o authorized
expense limit

Copyright 2013, Oracle and/or its affiliates. All rights


reserved.

work on

worked on
by

EVENT
# id
* name
* date
o description
* cost

Resolving Many-to-Many Relationships

Relationship Hiding an Attribute (cont.)


EVENT and PARTNER

When an EVENT
PLANNER, a DJ, or a
PROJECT MANAGER
works on an EVENT, we
want him to record the
status of the job.

PARTNER
# id
* first name
* last name

EVENT PLANNER
* expertise

DJ
* specialty

Which entity would the


attribute "status" belong
to?

Copyright 2013, Oracle and/or its affiliates. All rights


reserved.

MANAGER
o authorized
expense limit

work on

worked on
by

EVENT
# id
* name
* date
o description
* cost

Resolving Many-to-Many Relationships

Resolution of a M:M Relationship


A third entity is needed to resolve the M:M relationship.
This is called an "intersection" entity.

Copyright 2013, Oracle and/or its affiliates. All rights


reserved.

Resolving Many-to-Many Relationships

Intersection Entity
JOB ASSIGNMENT
o status

An intersection entity
JOB
ASSIGNMENT has
been added,
including the status
attribute. The original
M:M relationship has
become two 1:M
relationships. What
would be the UID of
the intersection
entity?
7

Copyright 2013, Oracle and/or its affiliates. All rights


reserved.

for

for

PARTNER
# id
* first name
* last name

EVENT PLANNER
* expertise

DJ
* specialty

MANAGER
o authorized
expense limit

responsible
for

the source of

EVENT
# id
* name
* date
o description
* cost

JOB ASSIGNMENT

Resolving Many-to-Many Relationships

Barred Relationships
JOB ASSIGNMENT
o status

The unique identifier


(UID) of the intersection
entity often comes from
the originating
relationships and is
represented by the
bars. In this case, the
relationships from the
originating entities to
the intersection entity
are called "barred"
relationships.
8

Copyright 2013, Oracle and/or its affiliates. All rights


reserved.

for

for

PARTNER
# id
* first name
* last name
responsible
for

the source of

EVENT
# id
* name
* date
o description
* cost

EVENT PLANNER
* expertise

DJ
* specialty

MANAGER
o authorized
expense limit

JOB ASSIGNMENT

Resolving Many-to-Many Relationships

M:M Resolution Example TV Shows


TV SHOW

Each TV show may


be watched by one or
more persons.

watched by

TV SHOW

watch

Each person may


watch one or more
TV shows.

Resolution of M:M
for

on

TV SHOW

Copyright 2013, Oracle and/or its affiliates. All rights


reserved.

PERSON

VIEWING
RECORD

for

on

PERSON

Resolving Many-to-Many Relationships

M:M Resolution Example Cleaning Services


Each company may
provide one or more
cleaning services.

CLEANING SERVICES

Resolution of M:M
for

on

CLEANING
COMPANY
Copyright 2013, Oracle and/or its affiliates. All rights
reserved.

CLEANING
SERVICE
provided by

Each cleaning
service may be
provided by one or
more companies.

10

provide

CLEANING
COMPANY

CLEANING
SCHEDULE

for

on

CLEANING
SERVICE

Resolving Many-to-Many Relationships

Terminology
Key terms used in this lesson included:
Barred relationship
Intersection entity

11

Copyright 2013, Oracle and/or its affiliates. All rights


reserved.

Resolving Many-to-Many Relationships

Summary
In this lesson, you should have learned how to:
Identify attributes which belong to many-to-many
relationships
Demonstrate the steps to resolve a many-to-many
relationship using an intersection entity
Identify the UID of an intersection entity and represent it
in the entity relationship diagram

12

Copyright 2013, Oracle and/or its affiliates. All rights


reserved.

You might also like