opensource.google.com

Menu

Lovefield: a powerful Javascript SQL-like database query engine for the web

Monday, November 17, 2014

Today we are announcing the release of a powerful library to be added to the arsenal of every web developer's toolbox. Since WebSQL standardization efforts ceased in 2010, there has been no cross-browser relational database solution for web clients. Existing persistence solutions such as IndexedDB and LocalStorage fall under the category of object-oriented storage and therefore lack traditional relational database features.


Lovefield is finally closing that gap by providing a feature rich database query engine built using IndexedDB as a backend. It provides an intuitive SQL-like declarative syntax such that developers can pick it up with minimal effort. Its declarative form provides immunity to SQL injection attacks, since there is no query parsing involved. The feature list includes:


  • select, insert, update, delete queries.
  • atomicity with intuitive transaction semantics (unlike IndexedDB’s surprising auto-commit behavior).
  • integrity constraint checks (primary key, unique, nullable/not-nullable).
  • aggregators (count, min, max, sum, avg, stddev, distinct)
  • "group by" for select queries.
  • multi-table join
  • easier schema upgrade mechanism than IndexedDB.
  • cross browser support (Chrome, Firefox, IE10).


On the performance front, Lovefield includes a query optimizer which will evaluate different execution plans and finally pick the most promising. We are confident that current performance will satisfy the majority of use cases (less than 50k rows) and we plan to further improve the performance for larger datasets in the near future.


Lovefield’s vision is captured in this specification document and we are working to provide some more exciting features such as foreign keys, cascaded delete/update, self-table join, observers/data-binding, in the near future.


Lovefield is already successfully powering a few Google services, including Google Play Movies Chrome app. With this open source release we are hoping to enable the development of data-rich applications and to attract interest and feedback from developers which will allow us to better understand how to move forward.


By Demetrios Papadopoulos, Chrome team
.