SeeNoWeevil
SeeNoWeevil

Reputation: 2619

Modelling an IndexedDB database in an offline web application with relational server-side data

I have application data that will be stored in SQL Server. This data will be synchronised to the user's browser via a REST API and persisted in an IndexedDB database for the user to make basic CRUD operations on and push back. The entities aren't particularly complex or large. Most users will have in the region of a couple of MBs of data. Given the context, the gains from storing this data client-side in a non-relational model, scalability and performance, seem like they don't apply. Would I gain more from storing this data in a relational way with foreign keys joining entities in IndexedDB object stores?

Serialising relational data into JSON on the server-side seems fairly trivial for both a relational structure or a document type structure using an ORM.

Upvotes: 0

Views: 767

Answers (2)

Uday
Uday

Reputation: 365

You can use an IndexedDB wrapper JsStore which probably resolve the difficulties of modelling an IndexedDB database with relational server-side data.

You can create tables in the IndexedDB of similar schema that you have on the server side with the help of JsStore and you just need to do basic CRUD operations on your IndexedDB tables using the help of APIs provided by the JsStore and will be easy to sync data with server side as you have a common schema both side.

For more details you can go through its official tutorial : JsStore Tutorial

Hopefully this may help.

Upvotes: 2

Josh
Josh

Reputation: 18690

Store data in a denormalized way in indexedDB. By that I mean look at which operations occur the most in your browser app. Generally these are reads that scan several objects in an object store. Renormalize the data into the form that makes the read operation fast.

Definitely do not use first normal form or whatever it is (sorry it has been years since Boyce-Codd) where you will have to do manual joins with indexedDB. This would be slow and not embrace the No-SQL ideology.

Upvotes: 0

Related Questions