sql query to mongodb?

2019-01-18 14:28发布

问题:

After seeing this image: http://2.bp.blogspot.com/_T-uXeKcGTnM/TIdoKBGwk9I/AAAAAAAABcs/CLW3_cRlN78/s1600/tumblr_kxovt0VLZy1qappj8.png I wonder is exists any tool for translating SQL querys into MongoDB map/reduce query model??

Larger version of the image: http://rickosborne.org/download/SQL-to-MongoDB.pdf

回答1:

The simple anwser? No.

The slightly more complex anwser is some people have had luck translating more complex SQL to Mapreduce functions ...

http://rickosborne.org/blog/index.php/2010/02/08/playing-around-with-mongodb-and-mapreduce-functions/

http://rickosborne.org/blog/index.php/2010/02/19/yes-virginia-thats-automated-sql-to-mongodb-mapreduce/

However, that said ... generally speaking you might as well learn mapreduce properly because if the data is in MongoDB already ... you'll really need to know how to properly query MongoDB to get anything meaningful done!

MongoDB has wonderful and helpful docs http://www.mongodb.org/display/DOCS/Advanced+Queries

As well as an easy to use online tutorial: http://try.mongodb.org/



回答2:

Update to the question asked in Jan 2011:

A couple of sites exist now to convert sql to mongodb.

Convert MySQL Queries to MongoDB Syntax http://www.querymongo.com/

And

Convert sql to mongodb http://klaus.dk/sqltomongodb/



回答3:

The simple answer: Yes. Hibernate OGM - JPA for NoSQL.

JPA is Java API for mapping objects to data stores.
It includes JPQL, a query language similar to SQL which adds the OOP concepts. It's not SQL, but you don't want pure SQL - that was designed for the relational paradigm.

Hibernate OGM proposes to simplify the programming model by embracing JPA/Hibernate APIs and semantics to store data in NoSQL stores like JBoss Enterprise Data Grid instead of the traditional RDBMS. (source)

Also see this Hibernate OGM: JPA for NoSQL talk by Hardy Ferentschik



回答4:

Recently I happened to see this website mongoquery.com, you can try it.



回答5:

Just to add to the last comment

re:The simple answer: Yes. Hibernate OGM - JPA for NoSQL.

JPA is Java API for mapping objects to data stores.
It includes JPQL, a query language similar to SQL which adds the OOP concepts. It's not SQL, but you don't want pure SQL - that was designed for the relational paradigm.

There is a company called UnityJDBC that has released a JDBC driver for Mongo that allows you to run SQL queries against mongo in any java application that supports JDBC.

you can download this driver free at http://www.unityjdbc.com/mongojdbc/mongo_jdbc.php

hope this helps



回答6:

You can also http://teiid.org which gives full range of SQL based access to MongoDB. You can use SQL through JDBC/ODBC or use REST/ODATA based access to MongoDB. Teiid uses MongoDB's aggregation framework to provide advanced SQL MongoDB query conversation.



标签: sql mongodb