matt3o matt3o - 1 year ago 89
reST (reStructuredText) Question

REST API using complex SQL Operations

I have a bunch of normalized tables, called

Now I have a three column table
representing the connection between the three tables. (column names
The normal endpoints like
show the elements of the according table.

/krt?where={result: module, danger_id: x}
would query the table
for all dangers with danger_id == x and join the result with the module table.
The result would look like (converted for displaying)

- module a
- module b
- module ..

I could of course provide a view and add a custom endpoint for this view. But there are not only three possible views but even more complex ones with one or two additional joins. (can also provide an example if needed)

Therefore is this kind of querying and joining a common concept or do I violate any of the REST constraints with this design? Is there any better / more intuitive way to provide such kind of information?

Answer Source

If you're asking about how would the RESTful URL would look, it might be something like


How you decide to build that SQL query is not related to RESTful design in my opinion.

There's also no guideline saying that every GET request has to be cacheable - it depends on other factors, too. If your data is fairly static, but requested often enough, then you might get away with caching it for even a short period of time.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download