Relationships Between Entities

If we are going to model a database as a collection of entity sets (tables), then we need to also 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).

The LIBRARY entity-relationship diagram

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.

Types of Relationships ...

Get Access Database Design and Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.