Part I – Writing Better, Faster and Easy to Maintain Mobile Apps with Realm
Writing Better, Faster and Easy to Maintain Mobile Apps with Realm

Part I – Writing Better, Faster and Easy to Maintain Mobile Apps with Realm

Writing Better, Faster and Easy to Maintain Mobile Apps with Realm

Part I - Writing Better, Faster and Easy to Maintain Mobile Apps with Realm

Working as a Senior Software Developer, I always find that Database configuration is quite a difficult process. While migrating data, updating database is a challenge. .

Recently, I bumped into a tool for Mobile Application developers. It’s called Realm. Realm is a mobile database which aims to replace CoreData and SQLite .

In fact, There are some of out-of-the-box benefits we get with Realm. It is a database platform with a distinct architecture, which has emerged as a new alternative to SQLite. .

SQLite

SQLite has a number of benefits of its own. We all acknowledge that one of which is its native support on Android. .

Directly dealing with SQL statements has number of downsides.

According to the official Android documentation, here are some steps which are needed to start reading/writing to SQLite:

  • Describe your schema in terms of contract classes.
  • Define your create/drop table commands in strings.
  • Extend SQLiteOpenHelper to run create commands and manage upgrades/downgrades.

Once all these steps are done, you are ready to read and write into your database. However, you will have to go back and forth between the objects in your application and values in the database. .

Another issue is maintainability. As your project grows large enough, the need to write complex queries arises & then you will end up with big chunks of raw SQL strings. If you ever need to change the logic of those queries, it can become quite a hassle.

Object-Relational Mapper

Instead of dealing with SQL, we can also use ORMs.

OrmLite, SugarORM, GreenDAO

ORM is a software library which, generally speaking, knows how to translate table rows into objects and vice versa. ORMs are widely used in virtually all object-oriented languages. .

They offer an object-oriented programming model of the database. The developers of an object-oriented language do not have to shift paradigms, each time they access the database. It does not make their job easier. While a query builder is not a necessarily part of an ORM library, most mature ORMs come with an SQL query builder. ORMs often help to manage the database creation process and database schema changes.

Realm

The Realm Mobile Database is built from the ground up to run on mobile devices. It’s not an abstraction on top of SQLite, but whole new database engine is written in C++. It currently supports Android, iOS ( Objective-C and Swift), Xamarin, and React Native.

The core concept of the Realm Mobile Platform is a lightweight object container. Like a database, data in Realms can be queried and filtered, interconnected, and persisted. Unlike a traditional database, though, objects in Realms are live and fully reactive. Realms synchronise seamlessly between devices and applications, and can be accessed safely across threads.

Next read: Implementation and Usage of Realm

  • Android
  • iOS
  • Mobile Apps
  • Mobile Database
  • Realm
Posted By

Rohan Pawar

Date

10 May 2017

Share
Stay updated with our Newsletter

Related Posts