10 Association resources
In this section, we'll explore a pattern for modeling many-to-many relationships between two resources using a separate association resource to represent the connection between the two. This pattern allows consumers to explicitly address an individual relationship between two resources as well as storing and managing extra metadata about that relationship.
10.1 Motivation
Most of the time, the relationships that we'll define between resources in an API will be simple and obvious. One reason for this is that they tend to be unidirectional in nature, acting as pointers or references going from one resource to another (e.g., Database 1 belongs to Project 1), as shown in Figure 10.X. When one resource type refers to another in this way, we say they have a one-to-many relationship. While these types of relationships are typically easy to manage when designing an API (often just a property referencing the other resource), there are other times where the relationships needed are more complicated and, as a result, are more difficult to express in an easy to use API.
Figure 10.X Uni-directional, or hierarchical, relationships between resources.
