You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Hendrik Jan van Meerveld <ha...@gmail.com> on 2011/05/17 05:32:34 UTC

SQL Query engine with views instead of tables

Hi all,

I'm using Couchdb for a new website and loving it.
The two tier setup with the database directly sending the HTML to the client
seems elegant to me.

One thing that I mis is SQL queries.
Somebody will probably say that I need to learn a new way of thinking, but
I've already been using Lotus Notes (another noSQL database) for 3 years and
I'm still missing SQL.

I've also recently noticed others on this mailing list that would benefit
from SQL queries:
- Alexander Gabriel: "Fetching data: how to
filter<http://www.google.nl/url?sa=t&source=web&cd=2&ved=0CCEQFjAB&url=http%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F201105.mbox%2F%253CBANLkTik8K6-ndbU9FFE%3DWO-HhcHhUFjejA%40mail.gmail.com%253E&rct=j&q=site%3Ahttp%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F%20Fetching%20data%3A%20how%20to%20filter&ei=IuvRTaT9CdGa-wbeoaXICg&usg=AFQjCNGkk2mJ-mrIrMyqbAAy4iJ3B5Hjdg&sig2=a5J_L6IDGtWBbq__4gng5Q&cad=rja>
"
- Mauro Fagnoni: "Convert data query into map/reduce
function<http://www.google.nl/url?sa=t&source=web&cd=3&ved=0CCwQFjAC&url=http%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F201105.mbox%2F%253CBANLkTimvXY0BUoZQ74Z8JPUZGMs4RwPCGw%40mail.gmail.com%253E&rct=j&q=site%3Ahttp%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F%20Convert%20data%20query%20into%20map%2Freduce%20function&ei=b-vRTaFahef6BqmwrOUK&usg=AFQjCNGwmdgGY_A0f_K-V-_taPVCThWX2w&sig2=Teio1B7yQrUPQManBwdxCQ&cad=rja>
"
- Fabio Batalha: "Querying inside a view
function<http://www.google.nl/url?sa=t&source=web&cd=1&ved=0CBkQFjAA&url=http%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F201105.mbox%2F%253CBANLkTik05ozk49Y-916efxTmDbqc5dZE9A%40mail.gmail.com%253E&rct=j&q=site%3Ahttp%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F%20Querying%20inside%20a%20view%20function&ei=qevRTfyaBo6e-Qb_6u3UCg&usg=AFQjCNHqK_A1hrA9Z0j0a0hcuhKK-Qf0fw&sig2=aKCwGNxwwlIhoR2OLmiI7A&cad=rja>
"

I found somebody who actually made a front-end SQL engine for Couchdb:
http://legitimatesounding.com/blog/NoSQL_meet_SQL.html

And there is a popular noSQL database that actually does queries:
MongoDB<http://www.mongodb.org/display/DOCS/Querying>



All this makes me ask the question: "Can SQL language not be added to
Couchdb?"
Views are after all very much like tables, so could an existing SQL query
engine not be rewritten to query tables in Couchdb?

So my question is, does anybody have some thoughts about this? Would it be
possible? Would it be difficult to implement in Erlang?


Kind regards,
Hendrik Jan

Re: SQL Query engine with views instead of tables

Posted by Hendrik Jan van Meerveld <ha...@gmail.com>.
Thank you for the reply Jim,

I'll look into Lucene someday.
Agree with you that the method for views feels more elegant that for lists.

Hendrik

On 17 May 2011 08:10, Jim Klo <ji...@sri.com> wrote:

> You effectively get close to that if you use CouchDB + Lucene.
>
> Alas not a 'native' solution either, but there is a very well defined query
> language for Lucene.
>
> I've wondered as well how difficult it would be to build a query optimizer
> that would effectively be a dynamic list.   One of the strengths relational
> db's have is the optimizer - essentially predetermining what key to use
> before scanning. Couch effectively has this albeit manually via lists. Maybe
> I'm missing something myself but, my biggest gripe about lists though is
> output in JSON feels like a kludge vs the method used for views. Output
> mechanisms should have some cardinality (I think I should be able to emit in
> a list vs having to JSONify output).
>
> - Jim
>
>
>
> On May 16, 2011, at 8:32 PM, Hendrik Jan van Meerveld <ha...@gmail.com>
> wrote:
>
> > Hi all,
> >
> > I'm using Couchdb for a new website and loving it.
> > The two tier setup with the database directly sending the HTML to the
> client
> > seems elegant to me.
> >
> > One thing that I mis is SQL queries.
> > Somebody will probably say that I need to learn a new way of thinking,
> but
> > I've already been using Lotus Notes (another noSQL database) for 3 years
> and
> > I'm still missing SQL.
> >
> > I've also recently noticed others on this mailing list that would benefit
> > from SQL queries:
> > - Alexander Gabriel: "Fetching data: how to
> > filter<
> http://www.google.nl/url?sa=t&source=web&cd=2&ved=0CCEQFjAB&url=http%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F201105.mbox%2F%253CBANLkTik8K6-ndbU9FFE%3DWO-HhcHhUFjejA%40mail.gmail.com%253E&rct=j&q=site%3Ahttp%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F%20Fetching%20data%3A%20how%20to%20filter&ei=IuvRTaT9CdGa-wbeoaXICg&usg=AFQjCNGkk2mJ-mrIrMyqbAAy4iJ3B5Hjdg&sig2=a5J_L6IDGtWBbq__4gng5Q&cad=rja
> >
> > "
> > - Mauro Fagnoni: "Convert data query into map/reduce
> > function<
> http://www.google.nl/url?sa=t&source=web&cd=3&ved=0CCwQFjAC&url=http%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F201105.mbox%2F%253CBANLkTimvXY0BUoZQ74Z8JPUZGMs4RwPCGw%40mail.gmail.com%253E&rct=j&q=site%3Ahttp%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F%20Convert%20data%20query%20into%20map%2Freduce%20function&ei=b-vRTaFahef6BqmwrOUK&usg=AFQjCNGwmdgGY_A0f_K-V-_taPVCThWX2w&sig2=Teio1B7yQrUPQManBwdxCQ&cad=rja
> >
> > "
> > - Fabio Batalha: "Querying inside a view
> > function<
> http://www.google.nl/url?sa=t&source=web&cd=1&ved=0CBkQFjAA&url=http%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F201105.mbox%2F%253CBANLkTik05ozk49Y-916efxTmDbqc5dZE9A%40mail.gmail.com%253E&rct=j&q=site%3Ahttp%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F%20Querying%20inside%20a%20view%20function&ei=qevRTfyaBo6e-Qb_6u3UCg&usg=AFQjCNHqK_A1hrA9Z0j0a0hcuhKK-Qf0fw&sig2=aKCwGNxwwlIhoR2OLmiI7A&cad=rja
> >
> > "
> >
> > I found somebody who actually made a front-end SQL engine for Couchdb:
> > http://legitimatesounding.com/blog/NoSQL_meet_SQL.html
> >
> > And there is a popular noSQL database that actually does queries:
> > MongoDB<http://www.mongodb.org/display/DOCS/Querying>
> >
> >
> >
> > All this makes me ask the question: "Can SQL language not be added to
> > Couchdb?"
> > Views are after all very much like tables, so could an existing SQL query
> > engine not be rewritten to query tables in Couchdb?
> >
> > So my question is, does anybody have some thoughts about this? Would it
> be
> > possible? Would it be difficult to implement in Erlang?
> >
> >
> > Kind regards,
> > Hendrik Jan
>

Re: SQL Query engine with views instead of tables

Posted by Jim Klo <ji...@sri.com>.
You effectively get close to that if you use CouchDB + Lucene. 

Alas not a 'native' solution either, but there is a very well defined query language for Lucene.

I've wondered as well how difficult it would be to build a query optimizer that would effectively be a dynamic list.   One of the strengths relational db's have is the optimizer - essentially predetermining what key to use before scanning. Couch effectively has this albeit manually via lists. Maybe I'm missing something myself but, my biggest gripe about lists though is output in JSON feels like a kludge vs the method used for views. Output mechanisms should have some cardinality (I think I should be able to emit in a list vs having to JSONify output). 

- Jim 



On May 16, 2011, at 8:32 PM, Hendrik Jan van Meerveld <ha...@gmail.com> wrote:

> Hi all,
> 
> I'm using Couchdb for a new website and loving it.
> The two tier setup with the database directly sending the HTML to the client
> seems elegant to me.
> 
> One thing that I mis is SQL queries.
> Somebody will probably say that I need to learn a new way of thinking, but
> I've already been using Lotus Notes (another noSQL database) for 3 years and
> I'm still missing SQL.
> 
> I've also recently noticed others on this mailing list that would benefit
> from SQL queries:
> - Alexander Gabriel: "Fetching data: how to
> filter<http://www.google.nl/url?sa=t&source=web&cd=2&ved=0CCEQFjAB&url=http%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F201105.mbox%2F%253CBANLkTik8K6-ndbU9FFE%3DWO-HhcHhUFjejA%40mail.gmail.com%253E&rct=j&q=site%3Ahttp%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F%20Fetching%20data%3A%20how%20to%20filter&ei=IuvRTaT9CdGa-wbeoaXICg&usg=AFQjCNGkk2mJ-mrIrMyqbAAy4iJ3B5Hjdg&sig2=a5J_L6IDGtWBbq__4gng5Q&cad=rja>
> "
> - Mauro Fagnoni: "Convert data query into map/reduce
> function<http://www.google.nl/url?sa=t&source=web&cd=3&ved=0CCwQFjAC&url=http%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F201105.mbox%2F%253CBANLkTimvXY0BUoZQ74Z8JPUZGMs4RwPCGw%40mail.gmail.com%253E&rct=j&q=site%3Ahttp%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F%20Convert%20data%20query%20into%20map%2Freduce%20function&ei=b-vRTaFahef6BqmwrOUK&usg=AFQjCNGwmdgGY_A0f_K-V-_taPVCThWX2w&sig2=Teio1B7yQrUPQManBwdxCQ&cad=rja>
> "
> - Fabio Batalha: "Querying inside a view
> function<http://www.google.nl/url?sa=t&source=web&cd=1&ved=0CBkQFjAA&url=http%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F201105.mbox%2F%253CBANLkTik05ozk49Y-916efxTmDbqc5dZE9A%40mail.gmail.com%253E&rct=j&q=site%3Ahttp%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fcouchdb-user%2F%20Querying%20inside%20a%20view%20function&ei=qevRTfyaBo6e-Qb_6u3UCg&usg=AFQjCNHqK_A1hrA9Z0j0a0hcuhKK-Qf0fw&sig2=aKCwGNxwwlIhoR2OLmiI7A&cad=rja>
> "
> 
> I found somebody who actually made a front-end SQL engine for Couchdb:
> http://legitimatesounding.com/blog/NoSQL_meet_SQL.html
> 
> And there is a popular noSQL database that actually does queries:
> MongoDB<http://www.mongodb.org/display/DOCS/Querying>
> 
> 
> 
> All this makes me ask the question: "Can SQL language not be added to
> Couchdb?"
> Views are after all very much like tables, so could an existing SQL query
> engine not be rewritten to query tables in Couchdb?
> 
> So my question is, does anybody have some thoughts about this? Would it be
> possible? Would it be difficult to implement in Erlang?
> 
> 
> Kind regards,
> Hendrik Jan