1{-# LANGUAGE OverloadedStrings #-}
2module ProjectM36.Key where
4import ProjectM36.Relation
5import qualified Data.Set as S
8keys can be implemented using inclusion dependencies as well: the count of the projection of the keys' attributes must be equal to the count of the tuples- p. 120 Database in Depth
11:showexpr ((relation{tuple{}}:{a:=S}):{b:=count(@a)}){b}
17((relation{tuple{}}:{a:=S{S#}}):{b:=count(@a)}){b}
24inclusionDependencyForKey :: AttributeNames -> RelationalExpr -> InclusionDependency
25inclusionDependencyForKey attrNames relExpr = --InclusionDependency name (exprCount relExpr) (exprCount (projectedOnKeys relExpr))
26 InclusionDependency equalityExpr (ExistingRelation relationFalse)
28 projectedOnKeys expr = Project attrNames expr
29 exprAsSubRelation expr = Extend (AttributeTupleExpr "a" (RelationAtomExpr expr)) (ExistingRelation relationTrue)
30 exprCount expr = projectionForCount (Extend (AttributeTupleExpr "b" (FunctionAtomExpr "count" [AttributeAtomExpr "a"])) (exprAsSubRelation expr))
31 projectionForCount expr = Project (AttributeNames $ S.fromList ["b"]) expr
32 equalityExpr = NotEquals (exprCount relExpr) (exprCount (projectedOnKeys relExpr))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list