Dajbych.net


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

, 3 minutes to read

Ob­ject ori­ented 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

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­sion pragma 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

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

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.