concept database in category haskell

This is an excerpt from Manning's book Get Programming with Haskell.
Reading from a database that could have null values
Listing 30.2. Basic setup for the problem of combining two Map lookups
import qualified Data.Map as Map type UserName = String type GamerId = Int type PlayerCredits = Int userNameDB :: Map.Map GamerId UserName #1 userNameDB = Map.fromList [(1,"nYarlathoTep") ,(2,"KINGinYELLOW") ,(3,"dagon1997") ,(4,"rcarter1919") ,(5,"xCTHULHUx") ,(6,"yogSOThoth")] creditsDB :: Map.Map UserName PlayerCredits #2 creditsDB = Map.fromList [("nYarlathoTep",2000) ,("KINGinYELLOW",15000) ,("dagon1997",300) ,("rcarter1919",12) ,("xCTHULHUx",50000) ,("yogSOThoth",150000)] #1 This Map represents the database you’re getting your UserName from, given a GamerId. #2 This Map represents the database; you’ll use the UserName to look up PlayerCredits. !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":6,\"ch\":60},{\"line\":6,\"ch\":62}],[{\"line\":22,\"ch\":0},{\"line\":22,\"ch\":2}],[{\"line\":14,\"ch\":60},{\"line\":14,\"ch\":62}],[{\"line\":23,\"ch\":0},{\"line\":23,\"ch\":2}]]"} !@%STYLE%@!
In this lesson, you’ll learn how to work with databases when using Haskell. In particular, you’ll use the SQLite3 relational database management system (RDBMS) and the sqlite-simple Haskell library. You’ll explore this topic by building a command-line interface for a tool-lending library. This will require you to perform all of the essential CRUD tasks commonly associated with RDBMS use. The CRUD tasks are as follows:
Create—Adding new data to the database Read—Querying the database for information Update—Modifying existing data in the database Delete—Removing data from the database You’ll use the sqlite-simple library to interact with your database. sqlite-simple is a mid-level abstraction over the database, meaning that while many of the low-level connection details are abstracted away, you’ll still be writing a large amount of raw SQL queries. The most important abstraction that sqlite-simple helps with is transforming SQL queries into lists of Haskell data types.