What is a realm?

I’m new to Realm and am trying to wrap my head around a few concepts. The documentation often refers to “a Realm” (example).

Is “a realm” a database instance?
Is “a realm” a database collection (i.e. many objects that share the same schema) ?

When planning an application (local use only, no sync), when does it make sense to use several “realms”, rather than a single “realm”?

Hi Adam

You can generally think of a realm as a database instance that maps to a .realm database file. It is not a “database collection” as you describe, rather it contains objects of one or more pre-defined types which can reference one another. I recommend reading the Realm Database fundamentals page in the docs for some more details.

When planning an application (local use only, no sync), when does it make sense to use several “realms”, rather than a single “realm”?

In most local-only use cases you could likely use only a single realm. There are some cases where you might split into multiple local realms, e.g. if you have some data that needs to be encrypted, but multi-realm apps are mostly useful for apps that use Partition-based Realm Sync.

1 Like