High-Level Database Models: Salary
High-Level Database Models: Salary
salary
Movies Stars
Contracts
length genre
Studios
name address
131
HIGH-LEVEL DATABASE MODELS
Stars Movies
Star−of Movie−of
Contracts
Studio Producing
of star studio
Studios
special-case entity sets, or subclasses, each with its own special attributes and/or
relationships. We connect an entity set to its subclasses using a relationship
called isa (i.e., “an A is a B” expresses an “isa” relationship from entity set A
to entity set B).
An isa relationship is a special kind of relationship, and to emphasize that
it is unlike other relationships, we use a special notation: a triangle. One side
of the triangle is attached to the subclass, and the opposite point is connected
to the superclass. Every isa relationship is one-one, although we shall not draw
the two arrows that are associated with other one-one relationships.
Example 10 : Among the special kinds of movies we might store in our exam-
ple database are cartoons and murder mysteries. For each of these special movie
types, we could define a subclass of the entity set Movies. For instance, let us
postulate two subclasses: Cartoons and Murder-Mysteries. A cartoon has, in
addition to the attributes and relationships of Movies, an additional relationship
called Voices that gives us a set of stars who speak, but do not appear in the
movie. Movies that are not cartoons do not have such stars. Murder-mysteries
have an additional attribute weapon. The connections among the three entity
sets Movies, Cartoons, and Murder-Mysteries is shown in Fig. 10. 2
132
HIGH-LEVEL DATABASE MODELS
Movies
Voices
Murder−
Cartoons Mysteries
is one root entity set (e.g., Movies in Fig. 10) that is the most general, with
progressively more specialized entity sets extending below the root in a tree.
Suppose we have a tree of entity sets, connected by isa relationships. A
single entity consists of components from one or more of these entity sets, as
long as those components are in a subtree including the root. That is, if an
entity e has a component c in entity set E, and the parent of E in the tree is
F , then entity e also has a component d in F . Further, c and d must be paired
in the relationship set for the isa relationship from E to F . The entity e has
whatever attributes any of its components has, and it participates in whatever
relationships any of its components participate in.
133
HIGH-LEVEL DATABASE MODELS
of Movies — Stars-in and Owns — that are not shown in Fig. 10).
A cartoon that is not a murder-mystery will have two components, one in
Movies and one in Cartoons. Its entity will therefore have not only the four
attributes of Movies, but the relationship Voices. Likewise, a murder-mystery
will have two components for its entity, one in Movies and one in Murder-
Mysteries and thus will have five attributes, including weapon.
Finally, a movie like Roger Rabbit, which is both a cartoon and a murder-
mystery, will have components in all three of the entity sets Movies, Cartoons,
and Murder-Mysteries. The three components are connected into one entity by
the isa relationships. Together, these components give the Roger Rabbit entity
all four attributes of Movies plus the attribute weapon of entity set Murder-
Mysteries and the relationship Voices of entity set Cartoons. 2
134
HIGH-LEVEL DATABASE MODELS
! c) Change your original diagram of Exercise 1.1 so that a customer can have
a set of addresses (which are street-city-state triples) and a set of phones.
Remember that we do not allow attributes to have nonprimitive types,
such as sets, in the E/R model.
1. For each team, its name, its players, its team captain (one of its players),
and the colors of its uniform.
3. For each fan, his/her name, favorite teams, favorite players, and favorite
color.
Remember that a set of colors is not a suitable attribute type for teams. How
can you get around this restriction?
b) Replace your ternary relationship with a new entity set and binary rela-
tionships.
! c) Are your new binary relationships the same as any of the previously exist-
ing relationships? Note that we assume the two players are different, i.e.,
the team captain is not self-led.
Exercise 1.5 : Modify Exercise 1.3 to record for each player the history of
teams on which they have played, including the start date and ending date (if
they were traded) for each such team.
! Exercise 1.6 : Design a genealogy database with one entity set: People. The
information to record about persons includes their name (an attribute), their
mother, father, and children.
! Exercise 1.7 : Modify your “people” database design of Exercise 1.6 to include
the following special types of people:
1. Females.
135