Couchbase and Mobile: A love story

The Mobile Landscape

Since the release of the first mobile apps, the technology landscape evolved drastically. It seems like only yesterday when the Apple App Store debuted with, what certainly feels like now, a measly 500 apps. A little over a decade later and what do we have to show for it? According to Statista, there are over two million apps within the two largest mobile platforms (Android and iOS).

Number of apps available in leading app stores as of 3rd quarter 2018

Global mobile data traffic from 2017 2022 (in exabytes per month)
Along with an increase of available apps, mobile device usage, as a whole, has also experienced rapid growth. According to GSMA, two-thirds of the world's population are now connected by mobile devices. It's projected, by 2020, that almost 75% of the population will be connected by mobile devices.


Ok, I know what you're thinking; "Yea, those are fascinating numbers, but where's the beef?"


An increase in mobile activity also means increased data storage and traffic. In fact, according to Statista,  the amount of mobile data traffic is expected to triple by 2022! 

Storing data on mobile device through an app can be done in many ways, but like on other platforms, when it comes to handling large amounts of information, there's no better option than a database. When considering database options, app developers will quickly approach a fork in the road; SQL or NoSQL. 

To SQL or not to SQL

SQL, or standard query language, is just that; a language. SQL is commonly used when referencing relational databases. SQL databases had been the defacto data storage approach taken by many developers for many years. However, about a decade ago the moniker of NoSQL was popularized to describe non-relational database options. Since that time, NoSQL implementations have been on the rise, but to gain some clarity as to why this is happening it is important to understand the differences between SQL and NoSQL. 

As previously mentioned, SQL based databases are relational. That means they are composed of rows and columns, in a tabular format, that allows for relationships to be created between other rows, columns, and tables. There are advantages and disadvantages to using relational databases, but when considering scalability and flexibility of mobile apps it's more important to focus on the potential hurdles SQL based databases present.  

Developing mobile apps with an underlying SQL based database can encounter many obstacles as the app scales:

  • Schema updates to account for new/changing business requirements can be costly and risky.
  • Increasingly complex queries hinder development time and app performance.
  • Asynchronous development complexity with large transactions hinders development time and performance.
  • Brittle data synchronization solutions.

NoSQL, or non-relational, databases serve to resolve many of the issues listed above. NoSQL databases are built for specific data models and have flexible schemas for building modern applications. While a SQL database focuses on reducing the amount of data storage redundancy, NoSQL focuses on performance, particularly as applications scale. 


There are two major advantages of NoSQL databases, particularly in a mobile setting:
  1. Ease of development. Mutable data models provide for more rapid development as they alleviate much of the risk you would encounter when updating SQL database schemas.
  2. Performance at scale. NoSQL doesn't require complex queries to combine pieces of data to get what you need. Instead data is organized, and stored in a self-contained manner that allows for much simpler, faster access.
Now that you're completely infatuated with NoSQL databases, what's next? A quick search will yield a plethora of options, but which one is the best? 

Couchbase Mobile to the rescue!

Image result for nosql database diagram
Couchbase Mobile is an extension of the Couchbase Data Platform. The Couchbase mobile database solution consists of two parts:

Couchbase Lite 

Couchbase Lite is an embedded lightweight, document-oriented (NoSQL), syncable database engine. It consists of a variety of "out of the box" features:

  • Enterprise-grade security
  • Muti-Dimensional Scaling: Delivers distributed architecture and provides compute, storage, and processing workload partitioning to provide maximum flexibility.
  • Peer-to-peer synchronization: Synchronize data directly from device-to-device via peer-to-peer without having to retrieve data from the cloud.
  • Full-Text Search: A search engine that examines all the words in every stored document that have indices set up to match against.
  • N1QL: A Couchbase query language that combines the power and familiarity of SQL with the flexibility and agility of the JSON data model. 

Couchbase Sync Gateway

Couchbase Sync Gateway allows for secure and automatic data synchronization between your web, mobile, and IoT apps (Couchbase Lite) and your backend database (Couchbase Server).

agile sync seamless data sharing


Couchbase Mobile's sync gateway eliminates the need to "roll your own" data synchronization functionality, and is considered to be one of, if not the, best mobile sync services on the market.

Mobile, NoSQL, and Couchbase: A match made in Heaven. 

It's not enough to simply read about utilizing NoSQL solutions you need to get your hands dirty. Please take a look at this sample app which demonstrates Couchbase's N1QL and Full-Text Search functionality. 

References

https://blog.couchbase.com/
https://mindsea.com/app-stats/
http://www.statista.com


Comments