DECOMPOSITION
(Handling Many to Many
relationships)
1
Aims:
◦ To demonstrate how to decompose
many:many (M:N) relationships
◦ To explain why M:N relationships need
to be decomposed.
2
A M:N relationship between 2 entity types must
be decomposed into two 1:M relationships.
3
M M
MODULE
STUDENT chooses
Becomes
1M M 1
STUDENT makes CHOICE for MODULE
4
M M
A rB
Becomes 1 M M1
A B
5
Naming the new entity type and the new
relationships is sometimes not easy
Often the old relationship name will help
you name the new entity. In the example
“chooses” became “choice”
If all else fails, concatenate (join) the
names of the 2 original entity types (e.g.
StudentModule).
6
Decompose this M:M relationship to form two 1:M
relationships:
M
DOCTOR treat PATIENT
Assign the new entity and relationship types
suitable names.
7
MM
DOCTOR do TREATMENT for PATIENT
8
Entity must have an identifier / keys.
The new entity type created by decomposition
needs an identifier
9
Back to the first example
Look at the original M:M relationship:
M M
STUDENT chooses MODULE
Student (student#, name, . . .)
Module (module#, description, . . .)
How do we know which students are taking
which modules?
We don’t.
10
M M
ACTOR appears FILM
in
Actor (actor#, name, . . .)
Film (film#, title, . . .)
Decompose this M:M relationship
Assign the new entity type an appropriate name
and think of some additional attributes for it
Assign the new entity type a suitable identifier /
key.
11
ACTOR make MM for FILM
APPEARANCE
12