10

TL;DR

What are the prospects of writing applications which are completely based on a REST database server (CouchDB) and web applications which directly access the DB instead of having a web server in between?


I recently started looking up some NoSQL databases. MongoDB seems to be a popular choices. I also liked the project.

But I personally liked the REST interface of CouchDB. So what I wanted to know is if there was the possibility of applications (maybe cached apps in web browser, a chrome extension etc.) which could just just query the database directly with no requirement of a webserver in between. All the computational logic would reside in the client application and the database will do what it does, CRUD. Since mostly (I don't know which doesn't) client frameworks support REST queries, it could be a good way of writing applications well optimized for the respective framework. These applications though won't be doing complicated computation, but still provide enough functionality which could replace lots of conventional applications.

Are there existing resources and projects which would help me move towards writing such applications and also the scope and moving towards developing in this way?

Are there any technical/security issues with this?


This post will help me decide to look into project like CouchDB (and maybe Dive into Erlang later) or stay with the conventional frameworks (like Django) and SQL databases.

Update

A specific point of such apps I had in mind is creation of offline applications just by replicating CouchDB data on the client.

8
  • You should read this: blog.couchbase.com/…
    – back2dos
    Jun 23, 2011 at 13:00
  • 2
    Not only is this trivial, but all RDBMS support this directly and (very) efficiently without the HTTP-based overheads of REST. What are you asking for?
    – S.Lott
    Jun 23, 2011 at 13:03
  • 1
    @crodjer: Oracle, MySQL, PostgreSQL, DB2, etc., all have direct SQL access from client to DB server. No REST. No Web Application. Just pure SQL. Have you looked at their documentation yet? What are you asking for?
    – S.Lott
    Jun 23, 2011 at 14:01
  • 1
    @S.Lott Browsers can access a remote MySQL server directly? @crodjer I would personally be worried about validation, security and authentication.
    – Raynos
    Jun 23, 2011 at 14:49
  • 1
    @Raynos: Where were browsers mentioned? RESTful web services are used by applications (sometimes written in JavaScript, but also written to run on desktops or smartphones.) Using raw SQL from an iPhone app through the internet to MySQL is trivial. It's directly supported out of the box. That's why the question is so confusing.
    – S.Lott
    Jun 24, 2011 at 1:33

5 Answers 5

4

You might like to read the write-up here.

The summary:

This was an experiment to see how easy it is to develop a simple Web site using CouchDB and (almost) nothing else. Ely Service is essentially a static Web site, and hence barely exploits any of the roaring power of CouchDB's B-Tree index or its distributed capabilities.

1
  • 3
    +1 for taking me to couchapp. HTML5 + python support would have been exactly the things which I would have looked for after the database.
    – crodjer
    Jun 23, 2011 at 13:39
4

it depends on how much you trust public users to CRUD all over your database objects. You still need an access API over your db to validate what operations are valid/permissible and which are not. That is why people create service tiers between clients and databases in the first place

now, i don't know CouchDB enough, but i don't think it takes into consideration such complex business permission logic by default. But even in that case, then the database is the web server too, you are just encoding the business logic differently

0

I read this CouchDB guide

The Standalone Applications page says it all.

From the page:

Because design documents can be replicated, whole CouchApps are replicated. CouchApps can be updated via replication, but they are also easily “forked” by the users, who can alter the source code at will.

These application are infact already more popular than I thought.

Update

It seems that this guide can answer most of my doubts and questions. I didn't read it in the first place, assuming it will only be a reference for the api and how to use the database. But it provides a really good overview about the CouchDB project.

0

So, you want to write client/server apps in HTML with some kind of JS framework? I guess that'd work, although I'm not sure I see the advantage over a simple web server. You've already got a server for the database, why not run Jetty or ligHTTPD to serve up some simple pages?

0

Even if you have a server layer to validate user read/write access to data, you would still risk someone manipulating your client side code in order to submit invalid data.

Any business constraint you may want to ensure should be validated server side. For example:

  • dates within valid ranges
  • valid names
  • block update to objects in a given state (like to avoid placing orders for items out of stock)
  • and any other business constraint you can think of.

All of these could be easily bypassed if you just have write permissions and all of your logic is client side.

Not the answer you're looking for? Browse other questions tagged or ask your own question.