Read Model data is best stored in Document databases


Last Updated on Feb 04, 2021

Typically, all data that will be persisted or exchanged should conform to Schemas. It is crucial to deliberately evolve these data structures over time.

But Read Models are best kept schemaless. The impermanent nature of data in Read Models does not justify the effort of maintaining schemas over time.

Most applications use relational database systems as their primary storage. RDBMSs enforce schemas by default - they need a structure to be present and active to persist or retrieve all data. This restriction is partly why NoSQL has gained popularity over the last two decades - there are situations where adhering to a schema is too much effort or simply impossible. Data from External systems and semantic data extracted by NLP from a document are great examples of such unstructured content.

Also, Document data models have excellent data locality. Relational databases involve joins because of how data is normalized, which impacts performance during query time, especially under heavy loads.

So the need for scalability and performance, and the schemaless nature, make Document databases a much better fit for managing Read Models. With the rise of NoSQL databases and the Document Data Model, there are now exciting options to choose from.

Elasticsearch offers optional support to handle schemaless data, but it also doubles up as a search index. There is no support for transactions at this time, but it is possible to work around the drawback if you understand that Denormalization does not eliminate the need for transactions.

Datomic can handle row-oriented, column-oriented, graph, and hierarchical data in a single system, including support for transactions. It is an ideal system when used in conjunction with Clojure and AWS.

VoltDB offers scalability and performance guarantees with NoSQL capabilities while integrating seamlessly with the rest of the tech infrastructure like distributed computing (Hadoop) and messaging systems (Apache Kafka).

Even MongoDB, a pioneer in the NoSQL database world, offers support for transactions to an extent. It supports atomic operations for making local modifications to a part of a JSON document.

Databases are increasingly merging the relational and document model worlds. But the transient, schemaless nature of Read Models seems to fit document-oriented databases better. Developers now have the advantage of choosing from a host of document stores with unique capabilities to solve their business problems perfectly.


© 2022 Ambitious Systems. All Rights Reserved.