I'm starting to work with RESTful services and I'm having doubts about many-to-many relationships. For example, suppose I have two Cliente
and Fornecedor
entities and that Cliente
has a list of providers, the providers from which it buys, and Fornecedor
has a list of customers who buy from it. Something like this
public class Cliente
{
// Propriedades da classe Cliente
public IList<Fornecedor> Fornecedores { get; set; }
}
public class Fornecedor
{
// Propriedades da classe Fornecedor
public IList<Cliente> Clientes { get; set; }
}
So if you want to expose this in a RESTful service what would be the best way to do it? I thought about exposing the following URL /clientes/{idCliente}/fornecedores
to get a client's vendors and then add or remove vendors from that client, but I'm finding this a bad option.
Basically because there would already be a /fornecedores
url that manages suppliers in general and putting this pros out of each client seems very strange to me.
So what is the best way to manage many-to-many relationships in api's restful?