algebra-sql-0.1.0.1: Relational Algebra and SQL Code Generation

Safe HaskellNone
LanguageHaskell98

Database.Algebra.Table.Construct

Contents

Description

This module contains smart constructors for table algebra plans.

Synopsis

Value and type constructors

int :: Integer -> AVal Source

Create a TA int value

string :: String -> AVal Source

Create a TA string value

bool :: Bool -> AVal Source

Create a TA boolean value

double :: Double -> AVal Source

Create a TA double value

dec :: Float -> AVal Source

Create a TA decimal value

nat :: Integer -> AVal Source

Create a TA nat value

intT :: ATy Source

Types of atomic values

stringT :: ATy Source

Types of atomic values

boolT :: ATy Source

Types of atomic values

decT :: ATy Source

Types of atomic values

doubleT :: ATy Source

Types of atomic values

natT :: ATy Source

Types of atomic values

Smart constructors for algebraic operators

dbTable :: String -> [(Attr, ATy)] -> [Key] -> Build TableAlgebra AlgNode Source

Construct a database table node The first argument is the emph{qualified} name of the database table. The second describes the columns in alphabetical order. The third argument describes the database keys (one table key can span over multiple columns).

litTable :: AVal -> String -> ATy -> Build TableAlgebra AlgNode Source

Construct a table with one value

litTable' :: [[AVal]] -> [(String, ATy)] -> Build TableAlgebra AlgNode Source

Construct a literal table with multiple columns and rows

eqJoin :: LeftAttr -> RightAttr -> AlgNode -> AlgNode -> Build TableAlgebra AlgNode Source

Join two plans where the columns n1 of table 1 and columns n2 of table 2 are equal.

rank :: ResAttr -> [SortSpec] -> AlgNode -> Build TableAlgebra AlgNode Source

Assign a number to each row in column ResAttr incrementally sorted by sort. The numbering is not dense!

difference :: AlgNode -> AlgNode -> Build TableAlgebra AlgNode Source

Compute the difference between two plans.

rowrank :: ResAttr -> [SortSpec] -> AlgNode -> Build TableAlgebra AlgNode Source

Same as rank but provides a dense numbering.

select :: Expr -> AlgNode -> Build TableAlgebra AlgNode Source

Select rows where the column SelAttr contains True.

distinct :: AlgNode -> Build TableAlgebra AlgNode Source

Remove duplicate rows

cross :: AlgNode -> AlgNode -> Build TableAlgebra AlgNode Source

Make cross product from two plans

union :: AlgNode -> AlgNode -> Build TableAlgebra AlgNode Source

Union between two plans

proj :: [Proj] -> AlgNode -> Build TableAlgebra AlgNode Source

Project/rename certain column out of a plan

aggr :: [(AggrType, ResAttr)] -> [(Attr, Expr)] -> AlgNode -> Build TableAlgebra AlgNode Source

Apply aggregate functions to a plan

rownum :: Attr -> [Attr] -> [PartExpr] -> AlgNode -> Build TableAlgebra AlgNode Source

Similar to rowrank but this will assign a unique number to every row (even if two rows are equal)

rownum' :: Attr -> [SortSpec] -> [PartExpr] -> AlgNode -> Build TableAlgebra AlgNode Source

Same as rownum but columns can be assigned an ordering direction

Lifted smart constructors for table algebra operators

eqJoinM :: String -> String -> Build TableAlgebra AlgNode -> Build TableAlgebra AlgNode -> Build TableAlgebra AlgNode Source

Join two plans where the columns n1 of table 1 and columns n2 of table 2 are equal.

rankM :: ResAttr -> [SortSpec] -> Build TableAlgebra AlgNode -> Build TableAlgebra AlgNode Source

Assign a number to each row in column ResAttr incrementing sorted by sort. The numbering is not dense!

differenceM :: Build TableAlgebra AlgNode -> Build TableAlgebra AlgNode -> Build TableAlgebra AlgNode Source

Compute the difference between two plans.

rowrankM :: ResAttr -> [SortSpec] -> Build TableAlgebra AlgNode -> Build TableAlgebra AlgNode Source

Same as rank but provides a dense numbering.

selectM :: Expr -> Build TableAlgebra AlgNode -> Build TableAlgebra AlgNode Source

Select rows where the column SelAttr contains True.

projM :: [Proj] -> Build TableAlgebra AlgNode -> Build TableAlgebra AlgNode Source

Project/rename certain column out of a plan

aggrM :: [(AggrType, ResAttr)] -> [(Attr, Expr)] -> Build TableAlgebra AlgNode -> Build TableAlgebra AlgNode Source

Apply aggregate functions to a plan

rownumM :: Attr -> [Attr] -> [PartExpr] -> Build TableAlgebra AlgNode -> Build TableAlgebra AlgNode Source

Similar to rowrank but this will assign a emph{unique} number to every row (even if two rows are equal)

rownum'M :: Attr -> [SortSpec] -> [PartExpr] -> Build TableAlgebra AlgNode -> Build TableAlgebra AlgNode Source

Same as rownum but columns can be assigned an ordering direction