Why is “Database Layer as a REST API” not common?

Swaroop C H wonders about an interesting architectural question - Why is “Database Layer as a REST API” not common?.

We have “database APIs” such as abstraction layers over multiple SQL databases and ORMs. But why not take it to the next step and make it a REST API like any other network call that we can make?

There is rarely a 1:1 correspondence between the DB schema and the REST API. At the minimum, you will want to drop administrative fields (addition/modification dates, foreign keys, etc).

Plus, there is a larger question of API fragility. DB to REST translators will break REST API’s with every DB change. This is why mechanisms like Django’s django-piston 1 are popular. With little code, one can control the mappings.

RethinkDB echoes a similar sentiment. From their FAQ.

If you are building an application that needs HTTP access to RethinkDB, we are sure that creating a RESTful interface that fits your needs would be a better solution than exposing the complete ReQL language over HTTP.

  1. Other Django options for exposing model APIs.