Syncing IndexedDB with Sql Server

前端 未结 4 1360
不思量自难忘°
不思量自难忘° 2020-12-29 15:23

I am doing offline DB connectivity in my page using HTML5 IndexedDB concepts.. But Initially, I want to fetch large datas to store it in my IndexedDb, so for that purpose, I

4条回答
  •  温柔的废话
    2020-12-29 16:09

    In addition to Editor and Kristof answers, I would like to add few more things since I've worked on a similar solution.

    • First of as Editor said IndexedDB is a document-oriented database while SQL is relational database which means that the you should convert your data to a object model before storing them locally
    • Avoid using multiple tables in IndexedDB and trying to create joins.
    • Additional tables in IndexedDB should be used if you store different objects in the database or you have additional data for your main object (example list of articles in one table - article text in the second table).

    Next thing is data synchronization - this can get really complicated if you update the data on both sides (client & server). The main problem that you'll be facing in the data synchronization is the fact that you'll have one main SQL database and a lot of local client databases.

    Here are couple things you should also consider:

    • You'll need to pick when to do the synchronization timed or by client request.
    • One other question that pops up is: What if the user works a lot of the time in the offline mode and updates an object which has been previously deleted by another user and that's stored to the SQL database.
    • And of course when you sync the data, split it into chunks, this will reduce the size of each response and IndexedDB works faster with smaller transactions.
    • I currently sync 500 items at a time (adjust this to the size of your objects)
    • Also in Chrome you can access IndexedDB from web-workers and make parallel requests - this can really speed things up.

    This are just some facts you'll need to consider before you start implementing the solution, hope it helps.

提交回复
热议问题