|
definition: |
newSuffix :: String -> [Attribute] -> [Relationship] -> String
newSuffix eName attrs rels =
let
generatedRs = filter isGeneratedR rels
exactRs = filter isExactB generatedRs --(i,i), i>1
maxRs = filter isMaxB generatedRs --(0,i), i>1
minMaxRs = filter isMinMaxB generatedRs --(i,j), i>0, j>i
in
concatMap ("With"++)
(map attributeName (filter isForeignKey attrs)) ++
if (length (exactRs ++ maxRs ++ minMaxRs))==0
then ""
else concatMap (\k->"With" ++ k ++ "Keys")
(map (relatedRelation eName)
(exactRs ++ maxRs ++ minMaxRs))
where
isExactB (Relationship _ [REnd _ _ _, REnd _ _ c]) =
case c of Exactly i -> i>1
_ -> False
isMaxB (Relationship _ [REnd _ _ _, REnd _ _ c]) =
case c of (Between 0 (Max i)) -> i>1
_ -> False
isMinMaxB (Relationship _ [REnd _ _ _, REnd _ _ c]) =
case c of (Between i (Max j)) -> i>0 && j>i
_ -> False
|
|
demand: |
no demanded arguments |
|
deterministic: |
deterministic operation |
|
failfree: |
<FAILING> |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_,_,_) |-> _}
|
|
name: |
newSuffix |
|
precedence: |
no precedence defined |
|
result-values: |
_ |
|
signature: |
String -> [Database.ERD.Attribute] -> [Database.ERD.Relationship] -> String |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |