concept relationship in category microservice

appears as: relationships, relationship, relationship, relationships
API Design Patterns

This is an excerpt from Manning's book API Design Patterns.

To address this concern, we can use an interesting tactic where we switch our focus away from lots of custom actions and instead shift toward a set of standard actions shared across the entire API (or in many cases across all APIs). Once we agree on a set of standard actions (most commonly these are Create, Get, List, Update, and Delete), we can design our API in terms of the things on which we can perform these standard actions. In other words, we focus on “nouns” (and relationships between them) instead of “verbs”. APIs that follow this pattern of thinking in terms of things rather than actions are called resource-oriented APIs.

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.

One of the most common types of these "more complicated" relationships is a many-to-many relationship, where resource types are associated with one another rather than one merely pointing to another. For example, let's imagine a scenario where we need to track people (users) and the various groups they belong to (groups). These users may be members of lots of different groups and, obviously, groups are made up of many different users as members. Additionally, there may be some specific information about the relationship itself that we want to keep track of. For example, maybe we want to store the exact time which a user joined a group or the specific role that they might hold in the group.