Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design pattern for a database application that must work disconnected

Tags:

.net

database

I have to design an application is mostly an interface with a database for data entry. The application must be able to work while it is disconnected from the database with cached data and insert that data when it has connection again. There will be two different modes, connected or disconnected, no need to detect disconnection in the middle of a connected session to switch to disconnected.

As this seems to me a common requisite i was wondering if there is a "standard" approach to face this problem. Caching tables to local file, serializing the data queried to the database or whatever. Maybe there is an existent library for doing that?

Thanks in advance.

PD: The application will be done in .Net

EDIT: Is a WinForms application, not a Web one.

EDIT2: To enter more detail about the application it is to enter data at one database, but sometimes users will be out of office several weeks and will need to enter data as if they were connected with cached data from the database and this data entered will be transfered to the database when they reconnect again.

like image 307
Ignacio Soler Garcia Avatar asked Jan 22 '10 07:01

Ignacio Soler Garcia


2 Answers

The scenario you are describing can be solved by database replication. For example, if you are using MS SQL server as your main C/S db, it can be replicated to a local MSSQL Express installation on your offline users workstation or notebook. As long as your users are out of office, the application has to connect to the local DB, and when coming back, the changes are replicated back to the central DB. I think this is the "standard" approach you are looking for, where you don't have to write special code for your offline situation (except for the code that changes the connection, and some code to start the replication).

It might be of interest for you that the CRM system used by our company works just like this, the local DB used is "MSSQL desktop engine", the predecessor of the Express edition, but IMHO this should work with the Express edition, too. As far as I know, you do not have to pay any licence fees for the MSSQL Express instances.

like image 98
Doc Brown Avatar answered Oct 31 '22 15:10

Doc Brown


ADO.NET in disconnected mode [PDF link] can be your starting point.

like image 1
Learning Avatar answered Oct 31 '22 17:10

Learning