How to choose the Right Mobile App Database for your Application?

Satyam Chaturvedi
11 min readFeb 8, 2021
Photo by CoinView App on Unsplash

Mobile applications hardly need any introduction considering their ubiquity in almost all spheres of human activity nowadays. This is also underscored by the industry estimates of $189 billion in revenue from mobile apps in 2020, which, ALL indicators show, will continue to increase steeply as IoT, 5G, and Cloud-based services mature and tap the opportunities from rapid ‘application’ of most IT services.

The most important aspect of a mobile application is its Database, which is also considered as the heart of a mobile app. A database is used to store and manage the data at the backend. If we talk about the mobile applications, it has databases operated on server-side or at the cloud, whereas the mobile handset communicates via cellular network or the Wi-fi network.

However, with the advent of technology, the usage of offline Databases has been increased, the mobile applications can place the Database locally, or can make a replica at the cloud, and synchronize the data to fulfill the required functionality of the mobile application. It offers faster access to the databases along with highly responsive applications, which are independent of internet connectivity limitations.

Mobile Database Models

From a developer’s perspective, we have the following database models available in the market.

Relational database model: This is a traditional database model, which classifies data through tables, and each table stores data in form of rows and columns. We have Data keys, which are used to identify a specific table and its constituent rows basis on the context and requirements of the end-user of the application.

Document-based: This database stores data in a definite structure made up of fields with several kinds of values, where each document can be represented via different fields. The document-based database supports complex hierarchies of documents which enables developers to embed them inside the mobile applications. This model is preferred by the developers for its flexibility, as it is not limited to fixed schemas.

Column-based: This model takes a cue from the traditional relational database model, however, the only advantage here is, that in this model the columns of data can have multiple values. It offers flexibility to fetch the data either by row or column as per the end-user requirements.

Graph: This database model stores data based on their internal relationships. This model offers an amazing navigation capability, which comes in handy while traversing across various data entities and fetching the data through the relationships.

Key Value-based: This model is highly popular for its simple approach and unmatched accessibility. This model of database stores data values with unique keys.

Choosing the right database for mobile app is not an easy task. This is a saturated market and every tweak that scores an improvement counts in the long run. In this piece, let’s dwell upon how one can maximize its usage, retention, and engagement.

Example schema– by Zaipuna Obedi Yonah, ResearchGate.

Factors in choosing a database

1. Type of data and platform: The search for a DBMS begins with identifying the type of data the application will be interacting with. Enterprise Mobile applications, Financial, Social media, Gaming, Cross-platform mobile applications have different data attributes that should be focused on while choosing the right Database solutions.

Use Data Modelling to map the needs of the applications by analyzing:

- Data Structure: How is data retrieved and stored.

- Data size: Quantity of data, servers, and file systems.

- Data velocity: The scaling of the database is heavily influenced by I/O operations performed by the app.

- Platform support: Is the application a cross-platform application? Or is it limited to one platform like Android, iOS?

Based on the data modeling, one of the databases could be chosen for the development of a mobile application. When there is a requirement of cross-platform mobile app development for support for more than one OS is required, multiple databases may be used in one app. It’s important to keep a flexible data model for ease in scalability or evolution.

· Relational DB: For highly structured data, stored in and retrieved from a set of data tables with described relationships. Most mobile apps use SQL RDBs as it helps save time collecting or writing data.

· Operational DB: For real-time DB updates of large datasets.

· Distributed DB: When geographically spread enterprises need database solutions at more than one site. They need to be synced in real-time, preferably with a point to point dedicated network link.

· End-User DB: To meet the demands from a different type of end-user community.

· Data Warehouse: For long time data storage.

2. Sync and offline capability: One of the most important trends in mobile app development has been to operate databases on the server or cloud side. As apps used to rely on network connectivity, increasingly the mobile apps place the DB locally or make a local copy of cloud database, utilize the synchronization and offline capabilities developed by DBMS and cloud services providers.

Couchbase Mobile, Azure Mobile Services, Cognito, etc. provide excellent sync capability.

The database chosen should have configurable sync settings; so that based on the requirement a proper replication-filtering & sync strategy could be deployed. The most common ones are push, continuous, polling, one-time, and streaming. As continuous sync is a drain on the network as well as device power consumption, synchronization should be taken as an optimization problem.

The sync settings should allow one to configure the DB partitions as such some components keep working offline. For example, a POS software [Point of Sale] should keep working even if there is no network connectivity to the global database. So, it’s configured in a tree topology so that it can sync with the store database when offline and can sync with the global database once connectivity is available.

3. Security: Data Privacy and Security are paramount concerns and failure to comply with security laws like GDPR for European Union and HIPAA for the USA, could be very costly.

A DBMS that facilitates secure authentication for data access is a must. The Database should also support file system encryption as well as data-layer encryption for data, either server or client. While committing the Data transaction, TLS or SSL channels should be supported.

4. Platform Support: In today’s fast-evolving marketplace, an Android or iOS mobile app might spread over and need desktop native apps as well on Windows or OS X laptops. As IoT and wearables interact more frequently with apps governable from mobile, such platforms may need to be supported as well. Hence, a pulse on the scope of the app also helps make the right choice for DB.

5. Robust data conflict resolution: When a platform uses decentralized write operations into a DB, conflicts invariably arise when the same data is simultaneously updated on more than one device. Timestamp(clock) based conflict resolution system creates issues due to clock differences across the client devices; so, a DB that supports a robust conflict resolution paradigm should be chosen. For example, Couchbase mobile uses revision trees — here the most active branch is taken as the final update.

6. Scalability and speed: When you think of scaling your application, you think of adding more resources in the form of servers and making the database engine more efficient. The database should be able to utilize the resources and handle the parallel processing, which means the Database must offer a multi-threaded mechanism. Multithreading mechanism offers an ability to the database to schedule parallel tasks as per the availability of the resources and in that way it helps to minimize the unnecessary workload at the server-side.

Apart from multithreading, a Distributed Design of a database can help is in scaling the applications in course of the future. In a distributed designed database, you can split up the services on different threads to minimize the workload on the main database. This drastically improves the parallel processing of databases. Choosing a proper DB engine and designing a robust schema for handling an increasing number of transactions per minute is a crucial piece of mobile app architecture. So, developers should choose the type of DBMS that meets the need of the application. For example, a healthcare PACS application may receive fewer queries but can be very data-intensive. On the other hand, a finance app may have a high very high number of transactions per minute.

7. Apps with Multiple layer Data: We have several complex applications that contain a multi-layer data model. Where one Data set could be dependent on another Data set. Such an arrangement makes it hard to manage and control the data for Mobile applications. Apart from that, another challenge is to cope with frequent changes in application and Data Structures.

The structured database like MySQL, PostgreSQL won’t offer flexibility to allow developers to make the changes on regular basis. On the other hand, the MongoDB (an unstructured Database) offers pathbreaking flexibility to implement changes without implementing a complex change process, which is the case with the structured databases. For example, MongoDB provides the freedom to work with data in multiple layers, it offers adequate flexibility to incorporate new mobile application features without making any drastic changes in the structure of an existing database.

8. Management of Network interrupts: This is one of the most critical factors while choosing the right database for Mobile applications. Mobile application database should offer adequate features to control and manage the issues while transferring the data over the mobile network. As most mobile applications use Cellular networks for their synchronization process, hence this parameter is indeed very critical while making a choice for Mobile app Databases.

For example, a SQL database generates an error message when it encountered an issue with the network connection while interacting with the client-end interface, it doesn’t transfer the data as requested by the end-user. The biggest disadvantage here is, if this problem occurs on regular basis, then developers have to make the necessary configuration changes in the database. To manage and avoid such network interruptions, we must choose a database that offers marginally better stability and resiliency to tackle such connection interrupt issues.

9. Handling of frequent Application and Database updates: Nowadays, it’s quite normal to make frequent changes in our Mobile applications, especially the security upgrades and app features upgrades. Such changes to the Mobile application required a certain level of modification in the local copy of the database as well. From the developer’s perspective, it is an extremely crucial operation, as they need to keep a track of old database versions while ensuring that the updated version works as per the client’s requirement.

Let’s understand this with an example, we may have an Application running version 1.0, and suppose we have recently pushed a version 3.0 for the same, note that users have to skip version 2.0 completely. The mobile application database, which we are considering for App development, should be capable enough to handle such complex situations. The database must have the capability to make changes in the tables, and at the same time, it should manage the old application programming interface and structure of the database for those users, who have been migrated to the newer version of the mobile application. For such a scenario, SQLite works really well, as it has an in-built OpenHelper tool, which keeps a track of database versions, it also offers call functions like onCreate or upgrade to manage the different versions of a Database.

10. Data conflict management between different devices: A Mobile application operates in a complex environment, where it has to commit the simultaneous update on user data available on multiple devices, such data modifications can create conflicts, which can lead to data loss or may result in data corruption as well. A mobile application database must have a mechanism in place to manage and resolve such conflicts.

11. Latency Management: This is another important factor to choose a mobile application database, especially when we develop Real-time mobile applications or an online gaming application, like PUBG. High latency can hamper the end-user experience and it may result in disrepute of the Application brand.

Technically speaking, any delay that ranges below 500 milliseconds could be considered as high latency. Reducing the latency is obviously not the function of a Mobile Database, however optimizing latency is something that can be handled at Database’s end, however, it’s a complex operation and had its own limitations for every mobile database. The most popular latency optimization technique is database replication.

We have few databases, which are known for their lower latency mechanism. MongoDB, PostgreSQL can be used for real-time transactional operations, PipelineDB and SQL database could be used for streaming applications, whereas RethinkDB can be used for a real-time complex application.

With keeping above parameters in mind, let’s look at some of the most popular Database solutions that are available in the market and review their salient features.

SQLite- Relational

Realm DB- Relational

ORM Lite- Object-Relational Mapping

Berkeley DB- Embedded DB

Couchbase Lite- NoSQL Embedded JSON DB

SQLite

· It’s a SQL open-source relational DB, compact and designed for mobile.

· Contains an in-process library implementing a self-contained, serverless, zero-configuration, transactional DB engine.

· Supports Android, iOS, Blackberry, Windows Phone OSes.

· Can be stored both in memory and on disk, and each DB file is a single disk file and can be used for cross-platform mobile application development.

· It is very fast and required quite less memory to operate. Can query up-to 20 records/sec.

Realm DB

· It’s a relational DB, but also has fully live and reactive objects. Objects always stay in sync.

· Cross-platform like SQLite, and serverless.

· Supports Android, iOS, JavaScript, etc.

· Automatic sync to Realm Object Server [when network connectivity is present]

· Can be directly connected to UI and it’ll auto-refresh.

ORMLite

· It is a lighter version of Object Relational Mapping. ORM wrapper over a mobile SQL related DB.

[ORM — It is a handy technique, which converts data between non-compatible systems using an appropriate object-oriented programming language]

· Used for applications with big and complex DB. ORMLite simplifies complicated SQL queries with a flexible query builder.

· It handles ‘compiled’ SQL statements for repetitive tasks, this is helpful with big apps. Supports table and field configurations without annotations, it also supports native calls to Android SQLite application programming interfaces, which is an extremely useful feature.

· It is slower than the SQLite and Realm DB, but comparatively much faster than other ORMs.

Berkeley DB

· It is an Open source, high performance embedded Database, which can work as relational DB as well as NoSQL DB depending on the library used and project requirement.

· Can handle data relationally like SQLite [by using own library instead of SQLite], also as Key/Value pair data with support for multiple data items for a single key.

· In scenarios of concurrent single write, multiple read operations — a combination of SQLite and Berkeley DB works faster and perform better.

Couchbase Mobile

· Couchbase Lite is a NoSQL embedded JSON database. It is highly scalable, and it supports enterprise-level security.

· Data is stored as JSON documents.

· Couchbase Mobile has three components — Couchbase Lite, embedded NoSQL database, Sync Gateway.

· Couchbase is an offline-first DB- it runs local and data persist in JSON and binary formats. The developer doesn’t have to write a sync code separately, as the data synchronizes local DB when the network becomes available using Sync Gateway.

· It also provides native APIs for Android and iOS; and plugins for Xamarin and PhoneGap.

· Very fast, reliable, and moderate in size - the best choice for a NoSQL DB.

Conclusion

Database management for a mobile application is a vast domain. An application development organization could be judged by its ability to maintain, manage and control the Data. This could be achieved only by choosing the correct type of mobile application Database. The above factors could be helping one to make the right choice while choosing the correct Database. Choosing a database is a strategic decision for any app development organization and the right choice can give your organization an upper hand over its rivals.

--

--