Search This Blog

Friday, November 12, 2010

SQL + NoSQL = SomeSQL

SQL + NoSQL = SomeSQL

Along with the NoSQL movement came a problem - how to query the data in distributed NoSQL databases?

A possible solution is to use both SQL and NoSQL. Imagine using a conventional RDBMS for indexing your data along with NoSQL database for storing actual data. Then query your index RDBMS with SQL and fetch full results from NoSQL buckets.

Modeling

  1. Determine what parts of your data do you want to index.
  2. Model your RDBMS by putting only index fields there.
  3. Each table that represents some entity must contain a NoSQL id which links to actual object in your distributed database.
  4. Model your NoSQL database so that it will store your objects in a serialized way (JSON, XML, ...).

Inserting
  1. Generate an identifier which will link your NoSQL entry with RDBMS. This can be some object hashcode or an SQL sequence value.
  2. Write your object into RDBMS (only indexed fields) providing the NoSQL ID. This can be done asynchroniously.
  3. Write your object into NoSQL DB.

Querying
  1. Query your RDBMS for indexed fields.
  2. Retrieve NoSQL ID from query results.
  3. Fetch objects from NoSQL DB using the NoSQL ID.

No comments:

Post a Comment