Chapter 9. Persistence

This chapter will cover interacting with persistent storage services. It will discuss a variety of ways to interact with the different types of storage available to cloud applications, such as relational databases and NoSQL stores. Next, it will show you how to use these kinds of storage from a modular application.

Relational Databases

The relational database has been part of enterprise applications for the last two decades. For most applications, it is the default choice for storing persistent data. Relational databases offer familiar concepts for storing data using the concepts of tables and rows.

In order to use a relational storage mechanism, a schema has to be defined up front. The schema defines the layout of the tables and how they interconnect to other tables using referential integrity mechanisms such as foreign keys.

The table design is such that data will be normalized, meaning that we structure the tables in such a way that avoids duplication or redundancy. Yet, there is a trade-off between normalization and development ease-of-use. If normalization is taken too far, it will be quite hard to work with the data model, especially with Object/Relational Mapping frameworks.

The main way of interacting with the database is through the use of a structured query language called SQL. SQL is pretty much standardized in a way that there is a general subset of commands and constructs that is shared across almost all databases. Sometimes a particular database offers ...

Get Building Modular Cloud Apps with OSGi now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.