0% found this document useful (0 votes)
6 views5 pages

High-Level Database Models: Salary

The document discusses high-level database models, focusing on entity-relationship (E/R) diagrams and the conversion of multiway relationships into binary relationships through connecting entity sets. It explains the use of subclasses in the E/R model, highlighting the 'isa' relationship that connects general and specialized entity sets, and illustrates this with examples from a movie database. Additionally, it provides exercises for designing various databases, emphasizing the importance of relationships and attributes in structuring data.

Uploaded by

khanhhun2k5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

High-Level Database Models: Salary

The document discusses high-level database models, focusing on entity-relationship (E/R) diagrams and the conversion of multiway relationships into binary relationships through connecting entity sets. It explains the use of subclasses in the E/R model, highlighting the 'isa' relationship that connects general and specialized entity sets, and illustrates this with examples from a movie database. Additionally, it provides exercises for designing various databases, emphasizing the importance of relationships and attributes in structuring data.

Uploaded by

khanhhun2k5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

HIGH-LEVEL DATABASE MODELS

salary

title year name address


Salaries

Movies Stars
Contracts

length genre
Studios

name address

Figure 8: Moving the attribute to an entity set

require binary relationships, it is useful to observe that any relationship con-


necting more than two entity sets can be converted to a collection of binary,
many-one relationships. To do so, introduce a new entity set whose entities we
may think of as tuples of the relationship set for the multiway relationship. We
call this entity set a connecting entity set. We then introduce many-one rela-
tionships from the connecting entity set to each of the entity sets that provide
components of tuples in the original, multiway relationship. If an entity set
plays more than one role, then it is the target of one relationship for each role.

Example 9 : The four-way Contracts relationship in Fig. 6 can be replaced by


an entity set that we may also call Contracts. As seen in Fig. 9, it participates
in four relationships. If the relationship set for the relationship Contracts has
a 4-tuple (studio1, studio2, star, movie) then the entity set Contracts has an
entity e. This entity is linked by relationship Star-of to the entity star in entity
set Stars. It is linked by relationship Movie-of to the entity movie in Movies. It
is linked to entities studio1 and studio2 of Studios by relationships Studio-of-star
and Producing-studio, respectively.
Note that we have assumed there are no attributes of entity set Contracts,
although the other entity sets in Fig. 9 have unseen attributes. However,
it is possible to add attributes, such as the date of signing, to entity set
Contracts. 2

1.11 Subclasses in the E/R Model


Often, an entity set contains certain entities that have special properties not
associated with all members of the set. If so, we find it useful to define certain

131
HIGH-LEVEL DATABASE MODELS

Stars Movies

Star−of Movie−of

Contracts

Studio Producing
of star studio

Studios

Figure 9: Replacing a multiway relationship by an entity set and binary


relationships

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

While, in principle, a collection of entity sets connected by isa relationships


could have any structure, we shall limit isa-structures to trees, in which there

132
HIGH-LEVEL DATABASE MODELS

Parallel Relationships Can Be Different


Figure 9 illustrates a subtle point about relationships. There are two differ-
ent relationships, Studio-of-Star and Producing-Studio, that each connect
entity sets Contracts and Studios. We should not presume that these rela-
tionships therefore have the same relationship sets. In fact, in this case, it
is unlikely that both relationships would ever relate the same contract to
the same studios, since a studio would then be contracting with itself.
More generally, there is nothing wrong with an E/R diagram having
several relationships that connect the same entity sets. In the database,
the instances of these relationships will normally be different, reflecting
the different meanings of the relationships.

length title year genre


to Stars

Movies

Voices

isa isa weapon

Murder−
Cartoons Mysteries

Figure 10: Isa relationships in an E/R diagram

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.

Example 11 : The typical movie, being neither a cartoon nor a murder-


mystery, will have a component only in the root entity set Movies in Fig. 10.
These entities have only the four attributes of Movies (and the two relationships

133
HIGH-LEVEL DATABASE MODELS

The E/R View of Subclasses


There is a significant resemblance between “isa” in the E/R model and
subclasses in object-oriented languages. In a sense, “isa” relates a subclass
to its superclass. However, there is also a fundamental difference between
the conventional E/R view and the object-oriented approach: entities are
allowed to have representatives in a tree of entity sets, while objects are
assumed to exist in exactly one class or subclass.
The difference becomes apparent when we consider how the movie
Roger Rabbit was handled in Example 11. In an object-oriented approach,
we would need for this movie a fourth entity set, “cartoon-murder-
mystery,” which inherited all the attributes and relationships of Movies,
Cartoons, and Murder-Mysteries. However, in the E/R model, the effect
of this fourth subclass is obtained by putting components of the movie
Roger Rabbit in both the Cartoons and Murder-Mysteries entity sets.

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

1.12 Exercises for Section 1


Exercise 1.1 : Design a database for a bank, including information about
customers and their accounts. Information about a customer includes their
name, address, phone, and Social Security number. Accounts have numbers,
types (e.g., savings, checking) and balances. Also record the customer(s) who
own an account. Draw the E/R diagram for this database. Be sure to include
arrows where appropriate, to indicate the multiplicity of a relationship.

Exercise 1.2 : Modify your solution to Exercise 1.1 as follows:

a) Change your diagram so an account can have only one customer.


b) Further change your diagram so a customer can have only one account.

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.

! d) Further modify your diagram so that customers can have a set of


addresses, and at each address there is a set of phones.

Exercise 1.3 : Give an E/R diagram for a database recording information


about teams, players, and their fans, including:

1. For each team, its name, its players, its team captain (one of its players),
and the colors of its uniform.

2. For each player, his/her name.

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?

Exercise 1.4 : Suppose we wish to add to the schema of Exercise 1.3 a


relationship Led-by among two players and a team. The intention is that this
relationship set consists of triples (player1, player2, team) such that player 1
played on the team at a time when some other player 2 was the team captain.

a) Draw the modification to the E/R diagram.

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

You might also like