Kinds of Relationships

When modeling a relationship between entities, it is important to determine both directions of the relationship. After both sides of the relationship have been determined, we end up with three main kinds of relationships. If both sides of the relationship have a degree of one and only one, it is called a “one-to-one” or “1-to-1” relationship. As we will find out later, one-to-one relationships are rare. We do not have one in our data model.

If one side has a degree of “one or many,” and the other side has a degree of “one and only one,” the relationship is a “one-to-many” or “1-to-M” relationship. All the relationships in our current data model are one-to-many relationships. This is to be expected since one-to-many relationships are the most common.

The final kind of relationship is where both sides are “one or many” relationships. These are called “many-to-many” or “M-to-M” relationships. In an earlier version of our data model, the Artist/CD relationship was a many-to-many relationship.

Get Managing & Using MySQL, 2nd 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.