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 Database.CDBI.ER
to provide type safety
when working with relational databases.
The tool erd2cdbi
generates from an entity-relationship model
a Curry program that represents all entities and relationships
by the use of this module.
Author: Mike Tallarek, changes by Julia Krone
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
Constructors:
ED
:: String -> [SQLType] -> (a -> [SQLValue]) -> (a -> [SQLValue]) -> ([SQLValue] -> a) -> EntityDescription a
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.
Constructors:
CD
:: [(Table,Int,[SQLType])] -> ([SQLValue] -> a) -> (a -> [[SQLValue]]) -> (a -> [[SQLValue]]) -> CombinedDescription a
A type representing tablenames
Type synonym: 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.
Constructors:
Column
:: 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
Constructors:
A constructor for CombinedDescription.
|
Adds another ED to an already existing CD.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|