12 Persistence: relational databases
This chapter covers
- What are relational data models and how to declare them
- Designing relational models with the HKD pattern
- What are SQL connectors in Haskell and what makes them difficult
We learned a lot about domain models in the previous chapters. In fact, a big fraction of the book was dedicated to the methodology known as domain-driven design. Although it’s a very good and very widespread methodology, it hasn’t always been so. Before the idea of designing systems from a domain point of view became popular, developers designed applications starting from a database model. They would first outline a relational representation of the task, and could then introduce the needed data structures in the code.
But this methodology had some flaws. The main disadvantage was that the database representation types had a significant bias in favor of a relational structure that wasn’t as intuitive as a domain-favored structure could be. It’s not really convenient to operate by the database model compared to the corresponding domain model. This distinction was rethought, and the approach “domain model first, database model second” began to prevail.