43
Realm Java Leonardo YongUk Kim [email protected]

Realm Java

Embed Size (px)

Citation preview

Realm JavaLeonardo YongUk Kim [email protected]

Yet another database?

No more SQL

String query = "SELECT " + Owner.NAME + ", " + Dog.NAME + ", " + City.NAME + " FROM " + Owner.TABLE_NAME

+ " INNER JOIN " + Dog.TABLE_NAME + " ON " + Owner.DOG_ID + " = " + Dog.ID

+ " INNER JOIN " + City.TABLE_NAME + " ON " + Owner.CITY_ID + " = " + City.ID

+ " WHERE " + Owner.NAME = "'" + escape(queryName) + "'";

Use cases

Fastest

Why is it so fast?

Traditional data structure

Column-based data structure

• Padding bits are not needed anymore. • Queries for columns help the cache hit rate. • Boolean type fields are put into integers field. • Other fields are packaged as 1, 2, 4, 8, 16, 32, 64bits. • More space efficient than SQLite (~50%)

How to use?

Extend RealmObject class

Create a standalone object, and then copy it to Realm

Instantiate through the Realm directly

Use realm.executeTransaction() method

Asynchronous transactions

Logical operators

Sorting

Chaining

Aggregation

Iteration

Deletion

Async queries

Async queries (cont.)

Relationships (Many-To-One)

Relationships (Many-To-One)

Link queries

RealmResults<Contact> contacts = realm.where(Contact.class).equalTo("emails.active", true).findAll();

Migrations

Migrations (cont.)

Encryption

Adapter