Pages

Thursday, June 14, 2012

Design of AlsoSQL: Drizzle JSON HTTP Server

This particular project was proposed by Henrik at Drizzle Day 2011. A week later, Stewart published version 0.1 of AlsoSQL. Later I and Henrik worked on version 0.2 and he talked about it at Drizzle Day 2012 .
AlsoSQL:Drizzle JSON HTTP Server, is capable of SQL-over-HTTP with key-value operation in pure json. Henrik explained about its working and functionality in this particular post
Here,I am going to talk about design of AlsoSQL and the various problems I faced.

Up-to version 0.2 , the API wasn't properly object oriented, so we planned to do re-factoring first.
After going through the code-base of AlsoSQL, I realized the need of design pattern. So we looked through various of them and chose Fascade design pattern for future development.

Here is the rough design of AlsoSQL (I called it rough because it might change in future).


Description:

HttpHandler is used to handle the http request ,parsing and validating json from that request and sending back response.
SQLGenerator simply generates the sql string corresponding to request type using input json.
SQLExecutor executes the sql and returns resultset.
SQLToJsonGenerator generates the output json corresponding to request type.
DBAccess is an interface to access generators and executor.

The main reason to design it in such a way is that it can be used over storage engine in future directly.

Problems Faced:
<config.h> , I always forgot to include this header file and it floods error on my terminal.
Another one , I need to get LAST_INSERT_ID() and I want to get it in a single query with REPLACE query. Still working on it.