Comparison of databases for UWP apps: SQLite, Realm & LiteDB

Comparison of databases for UWP apps: SQLite, Realm & LiteDB

Object oriented ap­pli­ca­tions usu­ally needs ob­ject ori­ented stor­age. Re­la­tions are good at map­ping poin­t­ers but many tech­ni­cal lim­i­ta­tions are hid­den un­der doc­u­men­ta­tion crust. It is not easy to choose the right database tech­nol­ogy be­cause pros are writ­ten ev­ery­where and cons are spread across many GitHub is­sues. It is like buy­ing a new car. You know the price, power and fuel con­sump­tion but you must in­quire into re­li­a­bil­ity and main­te­nance costs.

SQLite

  • Im­pos­si­ble to re­name or re­move ex­ist­ing ta­ble col­umn.

SQLite is writ­ten in C which lim­its UWP pro­ces­sor ar­chi­tec­tures to those that SQLite sup­ports be­cause Win­dows does not have SQLite build in. It is not big deal but Lit­eDB does not have this lim­i­ta­tion. SQLite re­quires SQLite for Uni­ver­sal Win­dows Plat­form Vi­sual Stu­dio ex­ten­sion which up­dates au­to­mat­i­cally but you need to man­u­ally recre­ate project ref­er­ence to SDK ev­ery time it hap­pens. Database ver­sion can be tracked by user_ver­sionpragma state­ment which is both sim­ple and ef­fec­tive. When you want use En­tity Frame­work Core you must tar­get at least Win­dows 10 Fall Cre­ators Up­date in which UWP sup­ports .NET Stan­dard 2.0.

Realm

  • Doesn’t sup­port Uni­code char­ac­ters in file paths.
  • Doesn’t sup­port for­eign key in query.
  • Ob­ject prop­er­ties are ac­ces­si­ble only in­side us­ing block of the database con­text.
  • The query doesn’t sup­port mul­ti­ple val­ues in where clause.
  • It is im­pos­si­ble to use await in­side us­ing block of the database con­text.
  • Once set, the pri­mary key can­not be mod­i­fied.
  • The query doesn’t sup­port pro­jec­tion.

Realm lacks UTF-8 char­ac­ters sup­port for file paths. It means that Realm is not able to open a database file when user pro­file name con­tains char­ac­ters out­side ASCII ta­ble. This bug was per­sists more than one year af­ter be­gin­n­ing sup­port of UWP and no fix is planned. Realm is us­able only for An­droid or iOS en­vi­ron­ments. It also re­lies on Fody which in­jects some code changes in­side build pro­cess. When Fody up­dates build breaks.

LiteDB

  • When the query has more and op­er­a­tions en­gine will run only one con­di­tion with in­dex and other con­di­tions will use full scan.

Lit­eDB is writ­ten in C# which means it nicely fits Vi­sual Stu­dio, NuGet and .NET en­vi­ron­ment. It re­quires .NET Stan­dard 1.3 which is im­ple­mented since UWP 10.0.10240. It is very use­ful for sim­ple ap­pli­ca­tions but when data ma­nip­u­la­tion re­quires com­plex rules and per­for­mance has a high pri­or­ity it turns out that Lit­eDB needs some speed op­ti­miza­tions.

https://dajbych.net/comparison-of-databases-for-uwp-apps-sqlite-realm-litedb

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.