on master help sign in
add some notes on key inclusion dependencies for Maybe types
commitd99208cdc84736b76d1a1ed0937a49ab3831fc48 authorAgentM <agentm@themactionfaction.com> dateWed 14 Jun 2017, 18:22 (9 years ago) parent73b55b3
1 file changed+9
src/lib/ProjectM36/DataTypes/Maybe.hs+9
src/lib/ProjectM36/DataTypes/Maybe.hs+9
@@ -27,3 +27,12 @@ maybeAtomFunctions = HS.fromList [
2727 atomFuncBody = AtomFunctionBody Nothing $ \(defaultAtom:(ConstructedAtom dConsName _ (atomVal:_)):_) -> if atomTypeForAtom defaultAtom /= atomTypeForAtom atomVal then Left AtomFunctionTypeMismatchError else if dConsName == "Nothing" then pure defaultAtom else pure atomVal
2828 }
2929 ]
30+
31+{- To create an inclusion dependency for uniqueness for "Just a" values only
32+person := relation{name Text, boss Maybe Text}{tuple{name "Steve",boss Nothing}, tuple{name "Bob", boss Just "Steve"}}
33+:showexpr ((relation{tuple{}}:{a:=person where ^isJust(@boss)}):{b:=count(@a)}){b}
34+:showexpr ((relation{tuple{}}:{a:=person{boss} where ^isJust(@boss)}):{b:=count(@a)}){b}
35+constraint uniqueJust ((relation{tuple{}}:{a:=person where ^isJust(@boss)}):{b:=count(@a)}){b} in ((relation{tuple{}}:{a:=person{boss} where ^isJust(@boss)}):{b:=count(@a)}){b}
36+person := relation{name Text, boss Maybe Text}{tuple{name "Steve",boss Nothing}, tuple{name "Bob", boss Just "Steve"}, tuple{name "Jim", boss Just "Steve"}}
37+ERR: InclusionDependencyCheckError "uniqueJust"
38+-}