Module Database.ERD

This module contains the definition of data types to represent entity/relationship diagrams and an I/O operation to read them from a term file.

Author: Michael Hanus, Marion Mueller

Version: April 2018

Summary of exported operations:

readERDTermFile :: String -> IO ERD   
Read an ERD specification from a file containing a single ERD term.
writeERDTermFile :: ERD -> IO String   
Writes an ERD term into a file with name ERDMODELNAME.erdterm and returns the absolute path name of the generated term file.

Exported datatypes:


ERD

Data type to represent entity/relationship diagrams. The components are the name of the ER model, the list of entities, and the list of relationships.

Constructors:


ERDName

The name of an ER model (a string).

Type synonym: ERDName = String


Entity

Data type to represent the entities of an ER model. Each entity consists of a name and a list of attributes.

Constructors:


EName

The name of an entity (a string).

Type synonym: EName = String


Attribute

Data type to represent attributes of entities of an ER model. Each attribute consists of

  • a name
  • the domain (i.e., type) of the attribute
  • a value specifying the key property of thi attribute (no key, primary key, or unique)
  • a flag indicating whether this attribute can contain null values

Constructors:


AName

The name of an attribute (a string).

Type synonym: AName = String


Key

Data type to represent key properties of attributes (no key, primary key, or unique).

Constructors:

  • NoKey :: Key
  • PKey :: Key
  • Unique :: Key

Null

Type of the flag of an attribute indicating whether the attribute can contain null values (if the flag has value True).

Type synonym: Null = Bool


Domain

Data type the domain of an attribute. If the attribute has a default value, it can be specified as an argument in the domain.

Constructors:

  • IntDom :: (Maybe Int) -> Domain
  • FloatDom :: (Maybe Float) -> Domain
  • CharDom :: (Maybe Char) -> Domain
  • StringDom :: (Maybe String) -> Domain
  • BoolDom :: (Maybe Bool) -> Domain
  • DateDom :: (Maybe CalendarTime) -> Domain
  • UserDefined :: String -> (Maybe String) -> Domain
  • KeyDom :: String -> Domain

Relationship

Data type to represent the relationships of an ER model. Each relationship consists of a name and a list of end points (usually with two elements).

Constructors:

  • Relationship :: RName -> [REnd] -> Relationship

RName

The name of a relationship (a string).

Type synonym: RName = String


REnd

An end point of a relationship which consists of the name of an entity, the name of the role, and a cardinality constraint.

Constructors:


Role

The name of a role (a string).

Type synonym: Role = String


Cardinality

Cardinality of a relationship w.r.t. some entity. The cardinality is either a fixed number (e.g., (Exactly 1) representing the cardinality (1,1)) or an interval (e.g., (Between 1 (Max 4)) representing the cardinality (1,4), or (Between 0 Infinite) representing the cardinality (0,n)).

Constructors:

  • Exactly :: Int -> Cardinality
  • Between :: Int -> MaxValue -> Cardinality

MaxValue

The upper bound of a cardinality which is either a finite number or infinite.

Constructors:

  • Max :: Int -> MaxValue
  • Infinite :: MaxValue

Exported operations:

readERDTermFile :: String -> IO ERD   

Read an ERD specification from a file containing a single ERD term.

writeERDTermFile :: ERD -> IO String   

Writes an ERD term into a file with name ERDMODELNAME.erdterm and returns the absolute path name of the generated term file.