chapter ten

10 Database operations

 

This chapter covers

  • Fetching data from the database
  • Storing data in the database
  • Manipulating data fetched from the database

10.1 A cloud is a cloud

Traditionally in Object-Oriented Programming we use design patterns and complex layers of objects to structure access to the database. In Data-Oriented Programming, we prefer to represent data fetched from the database with generic data collections, namely lists of maps where fields in the maps correspond to database column values. As we’ll see throughout the chapter, the fact that fields inside a map are accessible dynamically via their names, allows us to use the same generic code for different data entities.

In Data-Oriented Programming, data from the database is represented with generic data collections. This leads to:

  1. Reduced system complexity
  2. Increased genericity
[Tip]  Tip

The best way to manipulate data is to represent data as data.

In this chapter we illustrate the application of Data-Oriented principles when accessing data from a relational database. Basic knowledge of relational database and SQL query syntax (like SELECT, AS, WHERE and INNER JOIN) is assumed. This approach can be easily adapted to NoSQL databases.

Applications that run on the server usually store data in a database. In DOP, we represent data retrieved from the database the same way we represent any other data in our application: with generic data collections.

10.2 Fetch data from the database

10.3 Store data in the database

10.4 Simple data manipulation

10.5 Advanced data manipulation

10.6 Summary