Databases Reference
In-Depth Information
2.4.1 Types of Relationships
Referring to Figure 2-1, the symbols 1 and represent the type of relationship between
the corresponding entity classes. (The symbol is read “many.”) Relationships can be
classified into three types. For instance, the relationship between
Books
and
Authors
is
many-to-many,
meaning that a book may have many authors and an author may write
many books. On the other hand, the relationship from
Publishers
to
Books
is
one-to-
many
, meaning that one publisher may publish many books, but a book is published by at
most one publisher (or so we will assume).
One-to-one
relationships, where each entity on each side is related to at most one entity
on the other side of the relationship, are fairly rare in database design. For instance,
consider the
Contributors
-
Authors
relationship, which is one-to-one. We could replace
the
Contributors
class by a contributor attribute of the
Authors
class, thus eliminating the
need for a separate class and a separate relationship. On the other hand, if the
Contributors
class had several attributes that are not shared by the
Authors
class, then a
separate class may be appropriate.
In Chapter 3 we will actually implement the full E/R model for our LIBRARY database.