Databases Reference
In-Depth Information
{SocialSecurityNumber} and {FullName, FullAddress, DateofBirth} are keys for a
US
Citizens
entity class.
2.4 Relationships Between Entities
If we are going to model a database as a collection of entity sets (tables), then we also
need to describe the
relationships
between these entity sets. For instance, an author
relationship exists between a book and the authors who wrote that book. We might call
this relationship
WrittenBy
. Thus, Hamlet is
WrittenBy
Shakespeare.
It is possible to draw a diagram, called an
entity-relationship diagram,
or
E/R diagram,
to
illustrate the entity classes in a database model, along with their attributes and
relationships. Figure 2-1 shows the LIBRARY E/R diagram, with an additional entity
class called
Contributors
(a contributor may be someone who contributes to or writes
only a very small portion of a book, and thus may not be accorded all of the rights of an
author, such as a royalty).
Figure 2-1. The LIBRARY entity-relationship diagram
Note that each entity class is denoted by a rectangle, and each attribute by an ellipse. The
relations are denoted by diamonds. We have included the
Contributors
entity class in this
model merely to illustrate a special type of relationship. In particular, since a contributor
is considered an author, there is an
IsA
relationship between the two entity classes.
The model represented by an E/R diagram is sometimes referred to as a
semantic model
since it describes much of the meaning of the database.