7 Reasons to Manage Application Data via File System vs. DBMS

Introduction

Database management systems (DBMS) are popular as a uniform data storage, and they have become increasingly popular with the proliferation of mobile and web development, where file systems are either not available at all or have restricted access.

Such proliferation has caused a certain bias to using DBMS (and specifically SQLite as a built-in DBMS on mobile platforms) as a universal solution to data storage needs.

However, file systems are not a thing of the past. The advancement of mobile software brings back the necessity of design templates similar to those on desktop systems. In particular, the need arises to use files and file-based approaches to manage heterogeneous information. So, files are still in demand and they are more suitable for the classes of data management tasks discussed below.

Contents


Encryption

Data encryption is a complicated goal that is to some extent contradictory to the nature of DBMS. The database needs to know the size and in many cases the content of the data fields to operate efficiently. This limits flexibility in data management. Modern DBMS (mostly client-server ones) provide means to encrypt table fields, but on mobile devices these capabilities are absent. Also, field encryption doesn't hide metadata and doesn't disguise the structure of data and the number of entries. So, each developer needs to invent his own encryption schemes, and proper implementation of encryption is a goal that is hard to achieve.

Generally speaking, encrypting files and the file system is trivial nowadays. CBFS Storage implements on-the-fly encryption and decryption of files in streaming mode, so you (the developer) don't need to waste any time on it. Moreover, certain file systems, such as CBFS Storage, support both whole-storage and per-file encryption, and you can use different keys and encryption mechanisms for different files and the storage itself. CBFS Storage also offers callback mechanisms that enable you to configure your own encryption (e.g., certificate based).


Compression

Compression is very important on mobile devices, where the user pays for traffic and where the storage space is severely limited. Databases are space hungry and have no mechanisms for data compression, which leads to excessive complication in applications that need to deliver data in compressed form and then import them to the database (and even then uncompressed data takes precious space in device memory).

Modern file systems have built-in data compression implemented at the file level; i.e., you can compress all or some files as needed.


Versioning

Quite often, you have to keep several variants of the same named entity (be it a calendar record, a contact, a text note, or anything more complicated). Be it for a simple undo mechanism or logging, you need a place to store one or more versions of data. Alternate Data Streams support lets you store all variants in one file, so file operations like copying and moving perform operations on the same data.

To have versioning in a DBMS, you need to maintain a separate table or two, as there are no built-in mechanisms for versioning. With file systems, version management can be almost transparent — to create a version, you don't open the file itself, but its alternate stream. Just add a suffix to the filename.


Large and Heterogeneous Files

Relational databases were designed for storing uniform data with a predefined number and type of the fields for each record. Such a design is effective when processing large amounts of such uniform data but doesn't work well with objects that have different sets of properties. The necessity to manage such object sets lead to the creation of OODBMS (object-oriented DBMS) and later NoSQL DBMS. Still, SQL-based DBMS are mainstream, especially on mobile devices.

SQL-based relational DBMS don't handle large fields of undefined length (BLOBs) well. Such fields break the sleek structure of the DB table. arious DBMS offer different ways to manage BLOBs. Frequently, BLOBs are kept in separate files on the disk with references from the DB table. Other DBMS have a mini-file-system built into their engine to manage BLOBs and keep them in one file.

The prescribed way to work with BLOBs in DBMS requires an extra level of code that slows down operations with large data and does not add stability and reliability.

With a file system, you can have files as large as you want, and some file systems let you add custom properties (CBFS Storage calls them tags) to the files. Such properties let you organize object storage easily.


Remote and In-Memory Storage

The database in DBMS is almost always a set of files in local persistent storage (a file system or memory storage). Some DBMS allow the creation of in-memory tables for temporary operations, but migrating data to and from such memory storage is cumbersome.

Virtual file systems, such as CBFS Storage, allow you to keep storage anywhere - in memory, in a database (if needed), on a network disk, or in the cloud. Using callback mechanisms, CBFS Storage offers unprecedented flexibility in maintaining storage. Moreover, you can have on-the-fly mirroring of your storage, i.e., have a backup copy on the remote storage as soon as the storage is changed locally.


Easy Backup

A DBMS is not designed for easy backups. Rarely can you simply copy files from the DBMS — the restoration of these files becomes a tricky operation. More often you need to export the data to a large — and not easily maintainable — SQL file, which is then packed and stored somewhere. If you need to recover the data, you will need to execute this SQL file and potentially need to edit it.

In the case of file systems, backup and restore operations are trivial — you just copy the files or the container itself. In the case of CBFS Storage, which stores all files in single container, you can copy the container and then put it back and it will have everything that's needed to continue its work.

If you use mirroring as mentioned above, you have backups created on-the-fly.


Exposure to Other Applications

A final point of inefficiency with a DBMS is that you often need to expose the data contained within it as files for processing by other applications. There's no way to accomplish this task without external assistance. While on desktops you can use third-party solutions (e.g., CBFS Connect on Windows or FUSE on Linux) to expose custom data as files on mobile platforms this is not possible at all.

With "regular" (OS-provided) file systems such a task does not appear. CBFS Storage also lets you expose storages as virtual disks. CBFS Storage OS edition lets you create a virtual disk from CBFS Storage on Windows, macOS, and Linux systems (on mobile devices the functionality of OS edition can be accomplished with the Application edition).


Ready to get started?

Learn more about Callback Technologies or download a free trial.

Download Now