Composite Keys

Question: Composite Keys

Many existing web applications have to deal with mutliple ids (Composite Keys). Let’s say, order 4711 and order line 42, whereas the order lines are exposed via the rest API. How do we apply this to the REST URL structure?

1) orderlines/4711/42
2) orderlines(4711,42)

Are there any guidelines?


That is a good example for a subresource. You should design it like this:


If you want to expose orderlines as a top level resource and the orderline key is not unique over all orderlines in your internal model, you should create a separate unique key (e.g. a UUID) as additional key.