If you have a database in production in SQLServer, then you have no choice but to use it in effect. If it is a new database, I recommend you think well if you really need SQLServer.
- Do you need to keep records intensively?
- Is it possible that there are many writing operations at the same moment?
If the answer is yes to the questions then SQLServer is your best option. In applications where the writing is very intensive and where there can be multiple transactions in parallel, SQLite is not a good option because this engine only supports one transaction at the moment.
SQLite has a "locking" mechanism which locks the database in a writing application to ensure that there is only one transaction at a given moment
SQLite is a de facto alternative for mobile applications, it is fast, it is ACID compilant and above all, portable. 90% of the mobile applications you have installed, use this database engine.
Using an API to communicate remote database
It is not possible (at least, as far as I understand) to use SQLS in Cordova, I have not found plugin for this. However, even if there were, I think it would not be the optimal way to have a successful communication. A REST API is very useful in these scenarios, since the business logic is abstracted into a single service that can be shared among several clients.
For example, having an API, isolate all the logic of your system and from your Cordova application, web or even desktop, you could consume it and carry out the same operations, ignoring completely how they are implemented and what Database engine is used.
For example, the following actions can be consumed from any client:
-
GET /users
: get all users
-
GET /users/:id
: get a user by id
-
POST /users
: create a user
-
PUT /users/:id
: update a user
-
DELETE /users/:id
: delete a user
From your Cordova application you only have to use AJAX to communicate with the API:
$.ajax({
url: '/users',
type: 'GET'
dataType: 'json'
})
.done(users => {
// hacer algo con los usuarios
});
NOTE: If you use this method remember to set the origin
: <access origin="*" />
.