Chapter 6. Data Modeling
In the previous chapters, you looked at the Aerospike architecture and the facilities the database provides. In this chapter we will discuss how to model data in Aerospike to solve common problems. As with most databases, there are a variety of techniques that can be used to solve the same problem, so we will address some of the pros and cons of various approaches.
Note that there are many different ways to model data in Aerospike, and the appropriate technique depends on the problem trying to be solved. This chapter will introduce some of the more common techniques, but it is by no means exhaustive.
Aerospike Data Modeling
Aerospike supports records that have a structure similar to a relational database and it supports secondary indexes similar to a relational database, so it would seem intuitive that data modeling techniques would be similar to those used in relational databases. However, this is not always the case. To illustrate this, let’s look at a classical way of aggregating data.
Suppose you want to model a customer record. The customer has zero or more addresses associated with it, and the addresses have no business use if they are not associated with a customer. This is the classical case of aggregation and you can represent this as shown in Figure 6-1.
Figure 6-1. Entity–relationship model of a customer with their addresses
In a relational ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access