This module contains basic datatypes and operations to represent
a relational data model in a type-safe manner. This representation is
used by the library
to provide type safety
when working with relational databases.
generates from an entity-relationship model
a Curry program that represents all entities and relationships
by the use of this module.
The datatype EntityDescription is a description of a database entity
type including the name, the types the entity consists of, a function
transforming an instance of this entity to a list of SQLValues, a
second function doing the same but converting the key value always to
SQLNull to ensure that keys are auto incrementing and a
function transforming a list of SQLValues to an instance of this entity
Entity-types can be combined (For Example Student and Lecture could be
combined to Data StuLec = StuLec Student Lecture). If a description for
this new type is written CDBI can look up that type in the database
The description is a list of Tuples consisting of a String (The name of
the entity type that will be combined), a "rename-number" n which will
rename the table to "table as ntable" and a list of SQLTypes (The types
that make up that entity type). Furthermore there has to be a function
that transform a list of SQLValues into this combined type, and two
functions that transform the combined type into a list of SQLValues, the
first one for updates, the second one for insertion.
The list of sqlvalues needs to match what is returned by the database.
A type representing tablenames
Table = String
A datatype representing column names.
The first string is the simple name of the column (for example the
column Name of the row Student). The second string is the name of the
column combined with the name of the row (for example Student.Name).
These names should always be in quotes (for example "Student"."Name")
so no errors emerge (the name "Group" for
example would result in errors if not in quotes).
Has a phantom-type for the value the column represents.
:: String -> String -> Column a
Datatype representing columns for selection.
This datatype has to be distinguished from type Column which is just for
definition of conditions.
The type definition consists of the complete name (including tablename),
the SQLType of the column
and two functions for the mapping from SQLValue into the resulttype and
the other way around