Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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.

share|improve this question

marked as duplicate by maple_shaft Feb 22 at 14:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
You should read this: blog.couchbase.com/… – back2dos Jun 23 '11 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 '11 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 '11 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 '11 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 '11 at 1:33

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.

share|improve this answer

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?

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

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.

share|improve this answer
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 '11 at 13:39

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