Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web SQL Database or Indexed Database API ... or both?

HTML5's localStorage, while a great step in the right direction, is quite incomplete for my needs; its a glorified 1-dimensional array.

There are two competing client-side databases being built into modern browsers.

  • Web SQL Database (http://www.w3.org/TR/webdatabase/)
  • Indexed Database API (http://www.w3.org/TR/IndexedDB/)

Has anybody written and published a meta-library to both of these services? Akin to to how dojox.storage used to proxy the various plugins (http://dojotoolkit.org/api/1.3/dojox/storage/manager) would be great.

Futhermore, what has been your experience using either of these two 'standards'?

like image 654
Scott C Avatar asked Mar 07 '11 17:03

Scott C


People also ask

Is SQL a web database?

Web SQL Database is a deprecated web browser API specification for storing data in databases that can be queried using SQL variant. The API is supported by Google Chrome, Opera, and the Android Browser.

How many API modes does IndexedDB have?

Before creating the database I want to tell you about the two API modes of IndexedDB. Synchronous mode: This mode was created to be used only in conjunction with web workers. But most browsers currently do not support the synchronous mode.

What is IndexedDB and WebSQL?

IndexedDB used to have a competing spec called WebSQL Database, but it was deprecated by the W3C. While both IndexedDB and WebSQL are solutions for storage, they do not offer the same functionalities. WebSQL Database is a relational database access system, whereas IndexedDB is an indexed table system.

When should I use IndexedDB?

You might use IndexedDB to store structured data that's unrelated to any data on the server. An example might be a calendar, a to-do list, or saved games that are played locally. In this case, the application is really a local one, and your web site is just the vehicle for delivering it.


1 Answers

Actually there isn't two competing client-side databases being built into modern browsers, the Web SQL standard has been discontinued, in future versions of browsers there will only(*) be IndexedDB. Firefox will have it in 4.0, Chrome will have it sometime, IE will have it some time later and Opera will (so I've heard) have it in 11.50

(*)I say only, but I'm willing to bet WebKit will continue to support Web SQL for some time to come given that there's significant existing use out there, especially on iOS targeted stuff.

My personal opinion is that not blessing SQLite as a web standard is a good thing, but IndexedDB is not the thing to directly replace it. It's too low level to be really comfortable for front end developers to think about in the same way as SQL (if you've ever done that 'show execution plan' thing in SQL Server Studio, IndexedDB is basically the sort of thing you see there except without the handy diagrammatic comprehension aid). Having not yet devoted a serious chunk of time to understanding it, I haven't yet been able to figure out how to write a useful application with IndexedDB. My feeling is that it won't really take off until we see something like jQueryDB or possibly jsHibernate.

In the meantime, if a significant chunk of your users will be WebKit based, stick with Web SQL.

like image 134
robertc Avatar answered Oct 13 '22 00:10

robertc