Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Offline access - SQLite or Indexed DB?

I am in the R&D phase of developing an application, with the following key requirements:

  • HTML5 web application - which will also have a hybrid version
  • Forms data will be stored locally, when no Internet connection

I cannot use web storage due to quota limitations - I am comparing SQLite and Indexed DB.

  • SQLite seems to be best fit, but it is deprecated
  • Indexed DB is a good alternative, but there's no Safari support - A hybrid application is supposed to be run on the iPad and on an Android device in the future.

I am confused in the selection of API. Is there some other alternative to SQLite or support of Indexed DB expected on Safari?

like image 943
Taha Avatar asked Sep 03 '12 11:09

Taha


People also ask

Does IndexedDB work offline?

IndexedDB is provided by the browser and thus does not need internet for performing CRUD (Create Read Update Delete) operations.

Is SQLite an offline database?

SQLite can be used in Cordova applications to store a large number of records, including images, on mobile devices. In a Cordova application, you can use SQLite to store a large amount of information that can be accessed offline on a device.

Is SQLite offline or online?

No, sqlite is only for local, embedded databases.

When should you not use SQLite?

A good rule of thumb is to avoid using SQLite in situations where the same database will be accessed directly (without an intervening application server) and simultaneously from many computers over a network. SQLite will normally work fine as the database backend to a website.


2 Answers

I think abandoning IndexedDB would be a bad idea, because it's probably the format of the future, so Safari might stop supporting WebSQL.

It appears there are various JavaScript solutions to bridge the gap between the two - saving in whichever is available on the user's browser: JavaScript Library to Bridge IndexedDB and WebSQL I think this is probably your best solution.

like image 170
Robin Winslow Avatar answered Oct 02 '22 12:10

Robin Winslow


First of all, the one that has been deprecated by W3C is WebSQL not SQLite

IndexedDB -

  • It is incompatible with many types of mobile OS and is only compatible with certain types of versions of mobile OS
  • Developers cannot use SQL with IndexedDB. They can with SQLite and WebSQL
  • Most developers actively avoid using IndexedDB as much as they can

WebSQL -

  • It has been deprecated by W3C which means it is no longer maintained or developed
  • It requires another plugin called Polyfill to enable mobile applications to work with popular mobile OS such as Google Android and Apple iOS

SQLite -

  • It received an award from Google
  • SQLite has its official website. IndexedDB and WebSQL do not
  • On Google, SQLite returns 4.3 million results. WebSQL returns a bit less than 700K results and IndexedDB returns 282K results.

If you want a quick tutorial on SQLite,

Storage of SQLite database using Android and Phonegap

like image 42
KershawRocks Avatar answered Oct 02 '22 13:10

KershawRocks