liveBook · Manning

Key-value model

As explained in Functional Design and Architecture: Examples in Haskell

A key-value database model is a typed representation of the keys and values stored by a key-value database for particular entities.

A key-value model gives keys and stored values explicit types, then separates database representation from domain objects. Type classes define how entities become database keys and values, how values are serialized, and how decoded values return to application types. section 11.2.4

Loading a typed entity

A MeteorEntity can use MeteorKey as its key, encode its database value, decode stored bytes, and convert the resulting KVDBMeteor into the domain Meteor value. The generic loadEntity function composes those steps while preserving database and conversion constraints.

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Defines type-class interfaces and a generic loading pipeline, but defers broader primary-key design to relational databases.
Examples
Uses MeteorEntity, MeteorKey, KVDBMeteor, AstroDB, and the generic loadEntity function.
What it assumes
Assumes familiarity with typed values and type classes while making database-to-domain conversion explicit.
What you can do after
Build it from scratch by defining entity mappings and loading typed domain values through generic database functions.
How it connects
Links type classes, serialization, domain models, primary keys, and relational databases.

This explainer was generated by Manning's knowledge graph from the text of Functional Design and Architecture: Examples in Haskell. The section links point to the parts of the book it draws on.