Introduction to the 5 most popular embedded databases for mobile development

Introduction to the 5 most popular embedded databases for mobile development

[[120295]]

Embedded databases are lightweight, standalone libraries with no server components, no administration required, a small code size, and limited resource requirements. There are several embedded databases that you can use in your mobile applications. Let’s take a look at some of the most popular ones.

database

Data type storage

License Supported Platforms
BerkeleyDB relational, objects, key-value pairs, documents AGPL 3.0 Android, iOS
Couchbase Lite documents Apache 2.0 Android, iOS
LevelDB key-value pairs New BSD Android, iOS
SQLite relational Public Domain Android, iOS, Windows Phone, Blackberry
UnQLite key-value pairs, documents BSD 2-Clause Android, iOS, Windows Phone

Berkeley DB

Berkeley DB is an open source embedded database management system developed by Sleepycat Software of the United States (it has been acquired by Oracle). It provides scalable, high-performance, transaction-protected data management services for applications.

Berkeley DB (BDB) is an efficient embedded database programming library with corresponding APIs for C, C++, Java, Perl, Python, Tcl and many other languages. Berkeley DB can save any type of key/value pairs and can save multiple data for one key. Berkeley DB supports thousands of concurrent threads operating the database at the same time and supports up to 256TB of data. It is widely used in various operating systems, including most Unix-like operating systems, Windows operating systems and real-time operating systems.

Couchbase Lite

Couchbase Lite is an ultra-lightweight, reliable, and secure JSON database developed for online and offline mobile applications. Even under the most uncertain network conditions, it can provide your mobile applications with productive and reliable credibility. In addition, the 'Sync Portal' feature can also provide collaboration, social interaction or user updates.

Highlights of Couchbase Mobile Platform

JSON Anywhere

Use a flexible data model designed for object-oriented mobile apps that instantly adapts to your application needs without major changes to the application.

Easy Sync (Easy Sync)

Only a few lines of code are needed to get synchronization ready; allowing developers to focus more on application development rather than synchronization issues.

Native APIs

Manage your mobile database using APIs optimized for iOS and Android

REST APIs

Depending on your development needs, REST APIs provide an alternative access method.

LevelDB

LevelDB is a Key/Value storage engine open sourced by Google. It is written in C++ and supports high concurrent access and writing, which is particularly suitable for high-write business environments. For an overview of LevelDB, please refer to the description of LevelDB in Data Analysis and Processing 2 (Leveldb Implementation Principle). The diagrams in this article are more about the implementation layer of LevelDB, and the version is LevelDB 1.7.02.

LevelDB storage is mainly divided into SSTable and MemTable. The former is immutable and stored on persistent devices, while the latter is located in memory and mutable (there are two MemTables in LevelDB, one is the current write MemTable, and the other is the immutable MemTable waiting to be persisted). First, let's look at the implementation layer analysis of SSTable.

SQLite

SQLite is an open source embedded relational database that implements a self-contained, zero-configuration, transactional SQL database engine. It is highly portable, easy to use, compact, efficient, and reliable. Unlike other database management systems, SQLite is very simple to install and run. In most cases, just make sure that the SQLite binary file exists to start creating, connecting, and using the database. If you are looking for an embedded database project or solution, SQLite is definitely worth considering.

UnQLite

UnQLite is an embedded C language software library produced by Symisc Systems, which implements a self-contained, serverless, zero-configuration, transactional NoSQL database engine. UnQLite is a document storage database similar to MongoDB, Redis, CouchDB, etc. At the same time, it is also a standard Key/Value storage, similar to BerkeleyDB and LevelDB.

UnQLite is an embedded NoSQL (key/value store and document store) database engine. Unlike most other NoSQL databases, UnQLite does not have a separate server process. UnQLite reads/writes ordinary disk files directly. A complete database containing multiple data sets is stored in a single disk file. The database file format is cross-platform and a database can be freely copied between 32-bit and 64-bit systems or big-endian and little-endian architectures. The main features of UnQLite are as follows:

  1. `Serverless` database engine.
  2. `Transactional` (ACID) database.
  3. `Zero configuration`.
  4. `Single database file`, no temporary files are used.
  5. A `cross-platform` `file format`.
  6. UnQLite is a self-contained C library with no external dependencies.
  7. Standard `Key/Value` storage.
  8. A Document Store (JSON) database based on Jx9.
  9. Supports `cursor` to meet linear record traversal.
  10. `Plugable` runtime swappable storage engines.
  11. Supports both disk-persistent and memory-mode databases.
  12. Built-in powerful disk storage engine, supporting `O(1)` queries.
  13. `Thread-safe` and fully reentrant.
  14. Simple, clear, and easy to use API.
  15. Supports databases up to TB (Terabyte) size.
  16. Adopt `BSD open source license agreement`.
  17. Merge: All C source code files related to UnQLite and Jx9 are merged into a single file.
  18. Very good `online support`.

You can find more details on the UnQLite features page. (Think: how much of a SQLite flavor does this have?)

UnQLite is a self-contained C library with no external dependencies. It requires very little external libraries or support from the operating system. It is particularly suitable for use in embedded devices and also for internal applications (those that need to run on a large number of computers without modifying various configurations).

UnQLite is 100% hand-coded in ANSI C, thread-safe, fully reentrant, compiles without modification, and runs on most platforms, including constrained embedded devices, requiring only a C compiler. UnQLite has been tested on a wide range of platforms, including Windows and UNIX systems, especially Linux, FreeBSD, Oracle Solaris, and Mac OS X.

UnQLite is a standard key/value store, similar to BerkeleyDB and LevelDB. However, it has a richer feature set, including support for transactions (ACID), concurrent reads, etc. In KV storage, keys and values ​​are treated as simple byte arrays, so the content can be anything, including ASCII strings, binary objects, and disk files. Applications can access the KV layer through interface APIs, including

  1. unqlite_kv_store()
  2. unqlite_kv_append()
  3. unqlite_kv_fetch_callback()
  4. unqlite_kv_append_fmt()
  5. unqlite_kv_delete()

etc.

UnQLite's document storage interface for storing JSON documents (e.g., objects, arrays, strings, etc.) in a database is supported/implemented by the Jx9 programming language. Jx9 is an embedded scripting language, also called an extension language, designed for general procedural programming with data representation features. Jx9 is a Turing-Complete, JSON-based, dynamically typed programming language that exists as a library for the UnQLite kernel.

In short, UnQLite is an open source software, open source under the 2-Clause BSD license.

<<:  iPhone 6: The pain of mobile phone design revealed

>>:  Alternative fun: 10 programming language features that confuse programmers

Recommend

How do these five industries seize the dividends of Zhihu's advertising channel?

Which industries and companies have already condu...

Event planning: the underlying logic of events common to 360 industries

This article uses an interesting story in the for...

Insights: The harder it is, the more you should applaud yourself

Famous Artists Gallery | Lu Yifei, a native of Ch...

From 0 to 1, how to carry out overseas operations and promotion?

Establish a promotion and operation system around...

Major adjustment: Apple will allow one-click rating and reply to user reviews

At the end of January, Apple announced a major ne...