1module ProjectM36.DateExamples where
3import qualified ProjectM36.Attribute as A
5import ProjectM36.AtomFunctions.Basic
6import ProjectM36.DataTypes.Basic
7import ProjectM36.DatabaseContext
8import ProjectM36.Relation
9import qualified Data.Map as M
10import qualified Data.Set as S
12dateExamples :: DatabaseContext
13dateExamples = empty { inclusionDependencies = dateIncDeps,
14 relationVariables = M.union (relationVariables basicDatabaseContext) dateRelVars,
15 notifications = M.empty,
16 atomFunctions = basicAtomFunctions,
17 typeConstructorMapping = basicTypeConstructorMapping }
18 where -- these must be lower case now that data constructors are in play
19 dateRelVars = M.fromList [("s", suppliers),
21 ("sp", supplierProducts)]
22 suppliers = suppliersRel
23 products = productsRel
24 supplierProducts = supplierProductsRel
25 dateIncDeps = M.fromList [("s_pkey", simplePKey ["s#"] "s"),
26 ("p_pkey", simplePKey ["p#"] "p"),
27 ("sp_pkey", simplePKey ["s#", "p#"] "sp")
29 simplePKey attrNames relvarName = inclusionDependencyForKey (AttributeNames $ S.fromList attrNames) (RelationVariable relvarName ())
31suppliersRel :: Relation
32suppliersRel = case mkRelationFromList attrs atomMatrix of
36 attrs = A.attributesFromList [Attribute "s#" TextAtomType,
37 Attribute "sname" TextAtomType,
38 Attribute "status" IntAtomType,
39 Attribute "city" TextAtomType]
41 [TextAtom "S1", TextAtom "Smith", IntAtom 20, TextAtom "London"],
42 [TextAtom "S2", TextAtom "Jones", IntAtom 10, TextAtom "Paris"],
43 [TextAtom "S3", TextAtom "Blake", IntAtom 30, TextAtom "Paris"],
44 [TextAtom "S4", TextAtom "Clark", IntAtom 20, TextAtom "London"],
45 [TextAtom "S5", TextAtom "Adams", IntAtom 30, TextAtom "Athens"]]
47supplierProductsRel :: Relation
48supplierProductsRel = case mkRelationFromList attrs matrix of
52 attrs = A.attributesFromList [Attribute "s#" TextAtomType,
53 Attribute "p#" TextAtomType,
54 Attribute "qty" IntAtomType]
56 [TextAtom "S1", TextAtom "P1", IntAtom 300],
57 [TextAtom "S1", TextAtom "P2", IntAtom 200],
58 [TextAtom "S1", TextAtom "P3", IntAtom 400],
59 [TextAtom "S1", TextAtom "P4", IntAtom 200],
60 [TextAtom "S1", TextAtom "P5", IntAtom 100],
61 [TextAtom "S1", TextAtom "P6", IntAtom 100],
62 [TextAtom "S2", TextAtom "P1", IntAtom 300],
63 [TextAtom "S2", TextAtom "P2", IntAtom 400],
64 [TextAtom "S3", TextAtom "P2", IntAtom 200],
65 [TextAtom "S4", TextAtom "P2", IntAtom 200],
66 [TextAtom "S4", TextAtom "P4", IntAtom 300],
67 [TextAtom "S4", TextAtom "P5", IntAtom 400]
70productsRel :: Relation
71productsRel = case mkRelationFromList attrs matrix of
75 attrs = A.attributesFromList [Attribute "p#" TextAtomType,
76 Attribute "pname" TextAtomType,
77 Attribute "color" TextAtomType,
78 Attribute "weight" IntAtomType,
79 Attribute "city" TextAtomType]
81 [TextAtom "P1", TextAtom "Nut", TextAtom "Red", IntAtom 12, TextAtom "London"],
82 [TextAtom "P2", TextAtom "Bolt", TextAtom "Green", IntAtom 17, TextAtom "Paris"],
83 [TextAtom "P3", TextAtom "Screw", TextAtom "Blue", IntAtom 17, TextAtom "Oslo"],
84 [TextAtom "P4", TextAtom "Screw", TextAtom "Red", IntAtom 14, TextAtom "London"],
85 [TextAtom "P5", TextAtom "Cam", TextAtom "Blue", IntAtom 12, TextAtom "Paris"],
86 [TextAtom "P6", TextAtom "Cog", TextAtom "Red", IntAtom 19, TextAtom "London"]
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