A Quick Look at Open Source Databases for Mobile App Development
Data is the life blood of the IT world. It is generated in great volumes in the course of our everyday lives. Efficient data management calls for the use of database management systems (DBMSs). This article presents readers with a selection of popular ope
Organisations today have a wide choice when it comes to choosing efficient database management systems (DBMSs). Various IT giants like Oracle, Microsoft, IBM and SAP offer high-end solutions that address all sorts of database requirements. Even newer IT companies like Amazon, Google and Rackspace have entered the fray, offering cloudrelated features with regard to databases. According to Gartner analyst, Merv Adrian, 92.1 per cent of DBMS revenue comes from commercial software. Yet, new data is finding its way to open source databases as developers are opting for more convenience.
Open source cloud computing and database adoption is today widespread, as these databases provide huge benefits and are becoming a strong solution for every data management need within organisations. The DBMS space has been considerably impacted by the open source software (OSS) movement. The adoption of MySQL, MariaDB and other databases is saving organisations a lot of money, which would have otherwise been spent on licences and maintenance. Over recent years, various open source database projects have attained the maturity stage. In addition to cost savings, open source databases offer very easy tweaking, scaling and, overall, are feature-rich.
Apart from providing a solid backbone to enterprises in storing, retrieving and manipulating regular data during typical daytoday operations, open source databases are also becoming a strong choice for mobile app developers.
Mobile operating systems have gained much popularity. Android and iOS have surpassed Windows OS as the most used operating systems in the world. As mobile OSs and mobile hardware are becoming more powerful, with mobiles becoming fully functional smart computing devices, data computation from mobiles is also increasing.
Databases are regarded as the most obvious way of storing and manipulating data. In the beginning, databases on mobile apps were handled on the server side or on the cloud. Mobile devices only communicated with them via the network. However, with the passage of time, to make the applications more responsive and less network dependent, offline databases have been gaining popularity. Nowadays, mobile apps store entire databases on the phone or have the option of keeping the data on the cloud, with synchronisation once a day, depending on the network connectivity. This leads to faster and more responsive applications.
A mobile database is one that a mobile computing device can connect to over a wireless network. Mobile databases can further be classified as those that are physically separate from the central database server, those that reside on mobile
devices, and those capable of communicating with a central database server or other mobile clients from remote sites and handling local queries without connectivity.
Mobile DBMSs should satisfy the following requirements:
Small memory footprint
Flashoptimised storage system
Low power consumption
Strong coordination via embeddable features in applications There are many mobile databases available in the market with many new ones also emerging, but it is the developer who has to choose the right database that satisfies all the requirements of the particular mobile app being created.
A few popular open source databases designed especially for mobile apps are discussed here.
SQLite database is a small, highly reliable, embedded, fullyfeatured, compact and selfcontained relational DBMS available as a public domain software package. As compared to other database management systems, SQLite is not a clientserver database engine. It is regarded as a popular database, especially for application software like Web browsers and even for mobile app developers to store data from frontend mobile apps. SQLite offers an amazing set of tools to handle all sorts of data with ease and fewer constraints, compared to hosted and process based server relational databases.
Serverless: It doesn’t require a separate server process or system to operate. Its library has direct access to storage files.
Zero configuration: No server is required, which means ‘No setup’. Creating a SQLite database instance is as easy as opening a simple file.
Crossplatform: It is available for various platforms like Android, BSD, iOS, MAC, Solaris, Windows and VxWorks. Selfcontained: The entire database is contained in a single library and is integrated into the host application. Transactional: SQLite transactions are fully ACIDcompliant, which allows safe access from multiple processes.
Reliability: SQLite development is under consistent development and proper testing is done before launching new versions.
Fullyfeatured: It contains all the query language features found in the SQL2 standard.
SQL extensions: SQLite provides a number of enhancements to SQL, which are not normally found in other database engines. These enhancements include the EXPLAIN keyword and manifest typing. It also provides statements like REPLACE and the ON CONFLICT clause that allows for adding control over the resolution of the constraint conflict. It also supports the ATTACH and DETACH commands.
Official website: https://www.sqlite.org/
Latest version: 3.22.0
Object Relational Mapping Lite (ORMLite) facilitates simple, lightweight Object Relational Mapping (ORM) functionality for persisting Java objects to SQL databases by avoiding the overhead of other ORMs. It simplifies complicated SQL operations via a flexible query builder and provides powerful abstract Database Access Object (DAO) classes.
ORMLite supports JDBC connections to MySQL, Postgres, H2, SQLite, Derby, HSQLDB and Microsoft SQL Server, and can also be extended to various other databases. It supports native database calls on Android OS. ORMLite is bulkier than SQLite or Realm, but slower than both of them. It is regarded as faster than other ORM based databases.
As there is no JDBC support in Android OS, ORMLite makes direct calls to Android database APIs to access SQLite databases.
Provides a set of lightweight C# extension methods around .NET System.Data.* interfaces.
High performance database with support for indexes, text blobs, etc.
Supports crossplatform multiple databases like SQL Server, SQLite, MySQL, PostgreSQL and Firebird running on both .NET and Mono platforms.
Auto generates SQL to create and drop database tables. Has provisional support for DB2, Oracle, ODBC and Netezza.
Has powerful abstract Database Access Object (DAO) classes.
Official website: http://ormlite.com/
Latest version: 5.0
Berkeley DB is an open source, high performance, industry leading embeddable storage engine that provides developers a fast, reliable, local database with almost zero administration. It was primarily developed by Sleepycat Software but was acquired by Oracle in 2006. Berkeley DB is written in C language with API bindings for C++, C#, Java, Perl, PHP, Python, Ruby, Smalltalk, TCL and many other programming languages. It provides powerful APIs for many languages including Android and iOS.
Berkeley DB provides powerful robust data storage features like other traditional RDBMSs such as ACID transactions, and recovery, locking, multiprocess and multithreading for high concurrency, replication and hot and cold backup.
Oracle Berkeley DB: Berkeley DB has powerful architecture, which is very simple compared to other RDBMS software. Oracle added support for SQL in the 11g R2 release based on the popular SQLite API by including a version of SQLite in Berkeley DB.
All the powerful features of SQLite are included with Berkeley DB. As it includes the fullyfeatured SQL database engine, you can use JDBC, ODBC or any other compatible access layer as well.
Berkeley DB is highly flexible, and you can use it across a plethora of applications and as a replacement for custom, homegrown solutions. It provides fast, reliable and scalable persistence for applications that need to store data locally, run without interruption and access data in a predictable fashion.
The following are the three editions of Oracle Berkeley DB: Oracle Berkeley DB: Written in C. Current version: 6.2 Berkeley DB Java Edition: Written in Java. Current version: 7.5.11
Berkeley DB XML: Written in C++. Current version: 6.1.4
Data management: Fine grained and configurable locking for concurrent systems; sequential and indexed retrieval; stores data in-memory or on disk or a combination of both; strong encryption; library for data management to link embedded processes; and highly portable.
Transactions: ACID compliant, nested transactions, disaster recovery options, configurable graph, deadlock detection and log file archival.
Replication: Single and multiple replica models; delayed client synchronisation; scalable to thousands of replica nodes; nonstop upgrades; and PAXOScompliant election algorithm.
Deployment: Crossplatform, binary installer, open source and has a powerful administration.
Official website: http://www.oracle.com/technetwork/database/ databasetechnologies/berkeleydb/overview/index.html
Latest version: Berkeley DB 12Cr1 (126.96.36.199.32)
ObjectBox DB, developed by Greenrobot, is an objectoriented embedded database and is regarded as the best alternative to SQLite for mobile databases. It is specially designed for mobile database management and brings NoSQL Server technology to mobiles.
The guiding principle behind the ObjectBox DB design is, ‘Less code is better code’, which means ObjectBox DB is easy to work with even for newbies.
ObjectBox is a fully transactional database and consists of all the ACID features. It is a superfast mobile database that persists objects and enables users to avoid repetitive tasks, providing a simple interface to data.
The ObjectBox database extensions combine advanced enterprise application capabilities — selfadjusting connection pooling, transaction handling and RDBtoXML mappings — with a really straightforward o:XML interface.
ObjectBox DB is a fast, objectoriented mobile database for Android and Linux, and soon will support iOS. It supports JavaRx and Kotlin.
Fast: It is ten times faster than SQLite and delivers the best performance.
Object API: It builds objects from the ground up, i.e., there are no ORM, no SQLite, no rows and no columns. Powerful query builder: Simple queries for objects with consistent checks at the time of compilation. Crossplatform
Simple threading: Objects returned by ObjectBox work in all threads with no strings attached.
DaoCompat library: This is an addon library for greenDAO APIs for ObjectBox.
Support: It has an active community with more than 150,000 active users, and a strong team for active beta, unit and final testing.
Official website: http://objectbox.io
Latest version: 1.4.1
Realm DB (Real Mobile Database) is an open source database specifically designed for mobile devices from scratch, and is available for various platforms including Xamarin and React Native.
It is serverless and crossplatform like SQLite. Data can be stored on the disk as well as in memory.
The key difference between Realm and ORMs is that the former is not an abstraction built on top of SQLite, but a whole new database engine. Rather than a relational model, it is based on an object store. Its core consists of a selfcontained C++ library. It currently supports Android, iOS (ObjectiveC and Swift), Xamarin and React Native.
Realm is under active development and has been releasing updates pretty often. The development team is very responsive on the database’s issue tracker and StackOverflow.
Easytouse: Realm is very easy to use compared to CoreData and SQLite. Realm data models are defined using traditional NSObjectstyle classes with @properties. You can simply subclass RLMObject to create your
Realm data model objects.
Faster response: Realm is faster than other databases like SQLite, FMDB, CoreData and Couchbase Lite in app data storage. Even complex queries take nano seconds, and stay uptodate with new data.
Realm browser: This allows users to explore and administer realm databases.
Crossplatform: Available for Android, iOS and other popular mobile operating system platforms.
Data security: Provides enhanced security of data via transparent encryption and decryption.
Concurrency: Realm handles concurrency with MVCC architecture, and these views ‘automatically update’ when a transaction is committed from any thread. Support: Realm is highly supported via proper documentation, the community and is always updating to the latest features. It supports ObjectiveC as well as Swift, which suggests that this could be a longterm solution for iOS developers.
Official website: https://realm.io/
Latest version: 4.3.1
Couchbase Lite is a fullyfeatured open source NoSQL embedded JSON database designed for mobile devices.
Data in Couchbase Lite is stored as JSON documents.
Each document may have one or more attachments, which are essentially uninterpreted binary data that is stored and loaded separately from the document itself. Couchbase
Lite supports persistent indices (called views), and uses MapReduce to manage and query them.
Couchbase Mobile is the solution provided by Couchbase Lite for mobile applications. It comprises three different components: Couchbase Lite, an embedded NoSQL database and Sync Gateway. Couchbase is an offlinefirst database, and syncs with the cloud when needed or when the network is available. Couchbase Lite runs locally on the device and persists data as JSON and binary format. All CRUD operations are performed on the local database. Developers do not need to write sync code (if needed) to sync the local database with the cloud, as this is handled by Sync Gateway.
Couchbase Lite provides native APIs for Android and iOS with plugins for Xamarin and PhoneGap.
It is lightweight — just 500KB to 1MB.
Data is secured on the mobile device using 256bit AES encryption.
Synchronisation of data is from device-to-device via a peertopeer network.
Contains both REST APIs and native APIs for data management.
Crossplatform support available for Android, Mac, Windows and Linux.
Official website: https://www.couchbase.com/products/lite Latest version: 5.0
LevelDB is an open source database for mobile and Web apps, and was designed and developed by Jeffrey Dean and Sanjay Ghemawat of Google Inc. It is a simple, keyvalue store database built by Google. It is currently used in Google Chrome and other software. It supports arbitrary byte arrays as both values and keys; singular put, get and delete operations; batched put and delete; and bidirectional iterators. Simple compression is performed using the fast Snappy algorithm.
LevelDB is not an SQL database and doesn’t have a relational data model. It doesn’t support
SQL queries or indices. Applications make use of LevelDB as a library, and it doesn’t provide a server or command-line interface.
LevelDB is much better than SQLite and Kyoto Cabinet in terms of read and write operations, and also the best in batch writes. It also performs better in terms of read, write and synchronisationbased operations when compared to Berkeley DB and OpenLDAP Lightning DB.
LevelDB is written in C++. iOS developers can use it directly in their applications or through one of the several ObjectiveC wrappers that are available for it. Android developers can use LevelDB via JNI and NDK.
Makes multiple operations atomic.
Creates consistent snapshots.
Is iterative over key ranges.
Offers automatic data compression using the Snappy Compression library.
Basic operations: Put (key, value), get (key) and delete (key)
Facilitates transient snapshots for a consistent view of the data
Official website: http://leveldb.org/
Latest version: 1.14
The main design objective of UnQLite is to store information of all nodes like the IPaddress, blobs, etc. UnQLite was created by considering SQLite3 as the backend, i.e., the VFS layer, locking mechanism and Transaction Manager with Jx9.
UnQLite architecture: UnQLite is suitable for embedded devices and is written in ANSI C. It is thread safe, fully reentrant and compiles unmodified. It is available for various platforms like Windows, FreeBSD, Solaris, Mac and for mobile platforms.
JSON document store via Jx9
Pluggable runtime interchangeable storage engine Simple, clean and easytouse API
Supports terabytesized databases Official website: https://unqlite.org/ Latest version: 1.18
Realtime, fast synchronisation: Firebase uses data synchronisation—every time data changes, any connected device receives that update within milliseconds.
Offline access: Firebase apps remain responsive even when offline because the Firebase SDK persists your data to disk. Once connectivity is reestablished, the client device receives any changes it missed, synchronising it with the current server state.
Accessible via client devices: The Firebase realtime database can be accessed directly from a mobile device or Web browser; there’s no need for an application server. Security and data validation are available through its security rules, which are expressionbased rules that are executed when data is read or written.
Official website: https://firebase.google.com/
Figure 2: UnQlite architecture