You are on page 1of 7

ER-Diagram Examples

Ex. 1 - A Movie Domain


Domain Description:
• A movie has a title, a year and a length. Since
some movies have the same title, it takes a title
and a year to uniquely identify a movie.
• Some movies are remakes of others.
• A star has a name and an address. A star's
name uniquely identifies the star.
• A star can appear in any number of movies.

1
A Movie Domain
• Some movies have many stars and some have
none.
• A studio has a name and an address, and is
uniquely identified by its name.
• A star can belong to at most one studio.
• A studio can own any number of movies.
• A movie is always owned by at most one studio,
but some are not owned by any studio.

A Movie Domain
• A studio may or may not have a president, but
nobody can be a studio president without being
the president of some studio.
• Studio presidents are uniquely identified by their
name, but they also have an address.
• No one can be the president of more than one
studio.
• Stars and studio presidents are both examples
of movie people, but there are other types of
movie people as well.
• No star can be a studio president.

2
A Movie Domain
From the domain description we derive the entity
types and their attributes (including primary
keys):
• Entity types and their attributes:
– Movie
• title, year, length
– Star
• name, address
– Studio
• name, address
– Studio President
• name, address
– Movie People
• name, address

A Movie Domain
From the domain description we derive the
relationships between the entity types and
their cardinalities:
• Relationships:
– some movies are remakes of (exactly 1)
movie; each movie has (0 or more) remakes
– studios own (0 or more) movies; each movie
is owned by (at most 1) studio
– stars appear in (0 or more) movies; movies
have (0 or more) stars appearing in them

3
A Movie Domain

– stars belong to (at most 1) studio; studios


have (0 or more) stars belonging to them
– studio presidents are presidents of (exactly 1)
studio; studios have (at most 1) president
– stars and studio presidents are (disjoint but
incomplete) subtypes of movie people

ER-Diagram for the Movie Domain

• Once we have the entity types, the


attributes and the relationships, we can
produce the ER-Diagram for the domain.
• The ER-Diagram for the Movie Domain is
shown on the next slide.

4
remake-of

m o vie s tu d io
ow ns
title name
y ear addres s
length

appears -in m o vie -p e o p le pres ident-of

name
addres s

s tar s tu d io -p r e s

belongs -to

Ex. 2 - A Movie Domain


Domain Description:
• Add to example (1) that a contract is a
four-way relationship between a star, a
movie, the star's studio and the studio that
is producing the movie.
• Also add that a contract specifies the star's
salary for appearing in that movie.

5
Movie Domain 2
• New entity types and their attributes:
– Contract
• salary, star, movie title, movie year, star’s
studio, producing studio
• Contract is an associative entity type used
to represent a multi-way relationship. It is
therefore a weak-entity type. All of the
components of its primary key come from
identifying relationships.

Movie Domain 2
• New relationships (these are all identifying
relationships):
– a contract has (exactly 1) star; a star can have
(0 or more) contracts
– a contract has (exactly 1) movie; a movie can
have (0 or more) contracts
– a contract has (exactly 1) star’s studio; a
star’s studio can have (0 or more) contracts
– a contract has (exactly 1) producing studio; a
producing studio can have (0 or more)
contracts

6
ER-Diagram for Movie Domain 2
• The ER-Diagram for Movie Domain 2 is
shown on the next slide.

remake-of

s tudio
m ovie
ow ns
name
title
address
year studio-of -star
length

movie-of -contract
producing-studio
contr act

salary

appears-in president-of

m ovie -pe ople


star-of -contract
name
address

s tar s tudio-pre s

belongs-to

You might also like