14 Association resources

This chapter covers

  • How to handle many-to-many relationships with association resources
  • What name to choose for association resources
  • How to support standard methods for association resources
  • Strategies for handling referential integrity

In this chapter, 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.

14.1 Motivation

Most of the time, the relationships we’ll define between resources in an API will be simple and obvious because ...

Get API Design Patterns 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.