activefacts 1.6.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +14 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +60 -0
  8. data/Rakefile +3 -80
  9. data/activefacts.gemspec +36 -0
  10. data/bin/afgen +4 -2
  11. data/bin/cql +5 -1
  12. data/lib/activefacts.rb +3 -12
  13. data/lib/activefacts/{vocabulary/query_evaluator.rb → query/evaluator.rb} +0 -0
  14. data/lib/activefacts/version.rb +2 -2
  15. metadata +48 -296
  16. data/History.txt +0 -4
  17. data/LICENSE +0 -19
  18. data/Manifest.txt +0 -165
  19. data/README.rdoc +0 -81
  20. data/css/offline.css +0 -3
  21. data/css/orm2.css +0 -124
  22. data/css/print.css +0 -8
  23. data/css/style-print.css +0 -357
  24. data/css/style.css +0 -387
  25. data/download.html +0 -110
  26. data/examples/CQL/Address.cql +0 -44
  27. data/examples/CQL/Blog.cql +0 -54
  28. data/examples/CQL/CompanyDirectorEmployee.cql +0 -56
  29. data/examples/CQL/Death.cql +0 -17
  30. data/examples/CQL/Diplomacy.cql +0 -48
  31. data/examples/CQL/Genealogy.cql +0 -98
  32. data/examples/CQL/Insurance.cql +0 -320
  33. data/examples/CQL/Marriage.cql +0 -18
  34. data/examples/CQL/Metamodel.cql +0 -493
  35. data/examples/CQL/Monogamy.cql +0 -24
  36. data/examples/CQL/MultiInheritance.cql +0 -22
  37. data/examples/CQL/NonRoleId.cql +0 -14
  38. data/examples/CQL/OddIdentifier.cql +0 -18
  39. data/examples/CQL/OilSupply.cql +0 -53
  40. data/examples/CQL/OneToOnes.cql +0 -17
  41. data/examples/CQL/Orienteering.cql +0 -111
  42. data/examples/CQL/PersonPlaysGame.cql +0 -18
  43. data/examples/CQL/RedundantDependency.cql +0 -34
  44. data/examples/CQL/SchoolActivities.cql +0 -33
  45. data/examples/CQL/SeparateSubtype.cql +0 -30
  46. data/examples/CQL/ServiceDirector.cql +0 -276
  47. data/examples/CQL/SimplestUnary.cql +0 -12
  48. data/examples/CQL/Supervision.cql +0 -34
  49. data/examples/CQL/WaiterTips.cql +0 -33
  50. data/examples/CQL/Warehousing.cql +0 -101
  51. data/examples/CQL/WindowInRoomInBldg.cql +0 -28
  52. data/examples/CQL/unit.cql +0 -474
  53. data/examples/index.html +0 -420
  54. data/examples/intro.html +0 -327
  55. data/examples/local.css +0 -24
  56. data/index.html +0 -111
  57. data/lib/activefacts/cql.rb +0 -35
  58. data/lib/activefacts/cql/CQLParser.treetop +0 -158
  59. data/lib/activefacts/cql/Context.treetop +0 -48
  60. data/lib/activefacts/cql/Expressions.treetop +0 -67
  61. data/lib/activefacts/cql/FactTypes.treetop +0 -358
  62. data/lib/activefacts/cql/Language/English.treetop +0 -315
  63. data/lib/activefacts/cql/LexicalRules.treetop +0 -253
  64. data/lib/activefacts/cql/ObjectTypes.treetop +0 -210
  65. data/lib/activefacts/cql/Rakefile +0 -14
  66. data/lib/activefacts/cql/Terms.treetop +0 -183
  67. data/lib/activefacts/cql/ValueTypes.treetop +0 -202
  68. data/lib/activefacts/cql/compiler.rb +0 -156
  69. data/lib/activefacts/cql/compiler/clause.rb +0 -1137
  70. data/lib/activefacts/cql/compiler/constraint.rb +0 -581
  71. data/lib/activefacts/cql/compiler/entity_type.rb +0 -457
  72. data/lib/activefacts/cql/compiler/expression.rb +0 -443
  73. data/lib/activefacts/cql/compiler/fact.rb +0 -390
  74. data/lib/activefacts/cql/compiler/fact_type.rb +0 -421
  75. data/lib/activefacts/cql/compiler/query.rb +0 -106
  76. data/lib/activefacts/cql/compiler/shared.rb +0 -161
  77. data/lib/activefacts/cql/compiler/value_type.rb +0 -174
  78. data/lib/activefacts/cql/nodes.rb +0 -49
  79. data/lib/activefacts/cql/parser.rb +0 -241
  80. data/lib/activefacts/dependency_analyser.rb +0 -182
  81. data/lib/activefacts/generate/absorption.rb +0 -70
  82. data/lib/activefacts/generate/composition.rb +0 -118
  83. data/lib/activefacts/generate/cql.rb +0 -714
  84. data/lib/activefacts/generate/dm.rb +0 -279
  85. data/lib/activefacts/generate/help.rb +0 -64
  86. data/lib/activefacts/generate/helpers/inject.rb +0 -16
  87. data/lib/activefacts/generate/helpers/oo.rb +0 -162
  88. data/lib/activefacts/generate/helpers/ordered.rb +0 -605
  89. data/lib/activefacts/generate/helpers/rails.rb +0 -57
  90. data/lib/activefacts/generate/html/glossary.rb +0 -461
  91. data/lib/activefacts/generate/json.rb +0 -337
  92. data/lib/activefacts/generate/null.rb +0 -32
  93. data/lib/activefacts/generate/rails/models.rb +0 -246
  94. data/lib/activefacts/generate/rails/schema.rb +0 -216
  95. data/lib/activefacts/generate/records.rb +0 -46
  96. data/lib/activefacts/generate/ruby.rb +0 -133
  97. data/lib/activefacts/generate/sql/mysql.rb +0 -280
  98. data/lib/activefacts/generate/sql/server.rb +0 -273
  99. data/lib/activefacts/generate/stats.rb +0 -69
  100. data/lib/activefacts/generate/text.rb +0 -27
  101. data/lib/activefacts/generate/topics.rb +0 -265
  102. data/lib/activefacts/generate/traits/datavault.rb +0 -241
  103. data/lib/activefacts/generate/traits/oo.rb +0 -73
  104. data/lib/activefacts/generate/traits/ordered.rb +0 -33
  105. data/lib/activefacts/generate/traits/ruby.rb +0 -210
  106. data/lib/activefacts/generate/transform/datavault.rb +0 -266
  107. data/lib/activefacts/generate/transform/surrogate.rb +0 -214
  108. data/lib/activefacts/generate/version.rb +0 -26
  109. data/lib/activefacts/input/cql.rb +0 -43
  110. data/lib/activefacts/input/orm.rb +0 -1636
  111. data/lib/activefacts/mapping/rails.rb +0 -132
  112. data/lib/activefacts/persistence.rb +0 -15
  113. data/lib/activefacts/persistence/columns.rb +0 -446
  114. data/lib/activefacts/persistence/foreignkey.rb +0 -187
  115. data/lib/activefacts/persistence/index.rb +0 -240
  116. data/lib/activefacts/persistence/object_type.rb +0 -198
  117. data/lib/activefacts/persistence/reference.rb +0 -434
  118. data/lib/activefacts/persistence/tables.rb +0 -380
  119. data/lib/activefacts/registry.rb +0 -11
  120. data/lib/activefacts/support.rb +0 -132
  121. data/lib/activefacts/vocabulary.rb +0 -9
  122. data/lib/activefacts/vocabulary/extensions.rb +0 -1348
  123. data/lib/activefacts/vocabulary/metamodel.rb +0 -570
  124. data/lib/activefacts/vocabulary/verbaliser.rb +0 -804
  125. data/script/txt2html +0 -71
  126. data/spec/absorption_spec.rb +0 -95
  127. data/spec/cql/comparison_spec.rb +0 -89
  128. data/spec/cql/context_spec.rb +0 -94
  129. data/spec/cql/contractions_spec.rb +0 -224
  130. data/spec/cql/deontic_spec.rb +0 -88
  131. data/spec/cql/entity_type_spec.rb +0 -320
  132. data/spec/cql/expressions_spec.rb +0 -66
  133. data/spec/cql/fact_type_matching_spec.rb +0 -338
  134. data/spec/cql/french_spec.rb +0 -21
  135. data/spec/cql/parser/bad_literals_spec.rb +0 -86
  136. data/spec/cql/parser/constraints_spec.rb +0 -19
  137. data/spec/cql/parser/entity_types_spec.rb +0 -106
  138. data/spec/cql/parser/expressions_spec.rb +0 -199
  139. data/spec/cql/parser/fact_types_spec.rb +0 -44
  140. data/spec/cql/parser/literals_spec.rb +0 -312
  141. data/spec/cql/parser/pragmas_spec.rb +0 -89
  142. data/spec/cql/parser/value_types_spec.rb +0 -42
  143. data/spec/cql/role_matching_spec.rb +0 -148
  144. data/spec/cql/samples_spec.rb +0 -244
  145. data/spec/cql_cql_spec.rb +0 -73
  146. data/spec/cql_dm_spec.rb +0 -136
  147. data/spec/cql_mysql_spec.rb +0 -69
  148. data/spec/cql_parse_spec.rb +0 -34
  149. data/spec/cql_ruby_spec.rb +0 -73
  150. data/spec/cql_sql_spec.rb +0 -72
  151. data/spec/cql_symbol_tables_spec.rb +0 -261
  152. data/spec/cqldump_spec.rb +0 -170
  153. data/spec/helpers/array_matcher.rb +0 -23
  154. data/spec/helpers/ctrl_c_support.rb +0 -52
  155. data/spec/helpers/diff_matcher.rb +0 -39
  156. data/spec/helpers/file_matcher.rb +0 -34
  157. data/spec/helpers/parse_to_ast_matcher.rb +0 -80
  158. data/spec/helpers/string_matcher.rb +0 -30
  159. data/spec/helpers/test_parser.rb +0 -15
  160. data/spec/norma_cql_spec.rb +0 -66
  161. data/spec/norma_ruby_spec.rb +0 -62
  162. data/spec/norma_ruby_sql_spec.rb +0 -107
  163. data/spec/norma_sql_spec.rb +0 -57
  164. data/spec/norma_tables_spec.rb +0 -95
  165. data/spec/ruby_api_spec.rb +0 -23
  166. data/spec/spec_helper.rb +0 -35
  167. data/spec/transform_surrogate_spec.rb +0 -59
  168. data/status.html +0 -138
  169. data/why.html +0 -60
@@ -1,420 +0,0 @@
1
- <!--#include virtual="/header.html" -->
2
- <!--#include virtual="navbar.html" -->
3
-
4
- <link rel="stylesheet" href="../css/offline.css" media="screen" type="text/css" />
5
- <link rel="stylesheet" href="../css/print.css" media="print" type="text/css" />
6
-
7
- <div id="sidebar"></div>
8
-
9
- <div id="top" class="content">
10
-
11
- <h2>ActiveFacts Example Models</h2>
12
- <p class="offline noprint"><font size="-1">Copyright (c) 2007 Clifford Heath.</font></p>
13
-
14
- <!-- Things to show only in the offline version -->
15
- <div class="localnav offline noprint">
16
- <ul>
17
- <li id="nav-home"><a href="/" title="Home">Home</a></li>
18
- <li><a href="/ActiveFacts/" title="ActiveFacts Home">ActiveFacts Home</a></li>
19
- <li><a title="Start Here" href="#CompanyDirectorEmployee"> Start Here </a></li>
20
- <li><a title="Metamodel" href="#Metamodel"> Metamodel </a></li>
21
- <li><a title="All Examples" href="#AllExamples"> Table of all examples </a></li>
22
- </ul>
23
- </div>
24
-
25
- <p> ActiveFacts converts fact-oriented models into matching object-oriented and
26
- relational models. It accepts models in <a href="../CQLIntroduction.html">the Constellation Query Language</a> (CQL)
27
- or <a href="http://www.ormfoundation.org/files/">NORMA</a>, and emits CQL,
28
- Ruby, or SQL. This page contains many examples.</p>
29
-
30
- <p>The CQL files look like hand-written code, but they aren't.
31
- They're generated from the ORM2 files, and have not been edited.
32
- You can of course write them by hand.
33
- </p>
34
-
35
- <p>
36
- The ActiveFacts generator <em>afgen</em> does semantic analysis to convert these
37
- input files to SQL or Ruby, using the relational and object-oriented mapping algorithms.
38
- The Ruby code uses the Constellation API provided by the <em>activefacts</em> gem.
39
- </p>
40
-
41
- <p>
42
- To make a start learning Object Role Modeling, read the
43
- <a href="intro.html">Introduction to ORM2</a> or check the Resources page
44
- for other sites.
45
-
46
- </p>
47
-
48
- <p class="offline">
49
- If you're looking at a git clone of this project, and have Visual Studio (pro)
50
- on Windows with NORMA installed, you can open the Visual Studio solution
51
- <a href="norma/ExampleModels.sln">here</a>.
52
- Otherwise, you won't be able to edit the ORM2 files, but never fear,
53
- you can do all the same things by editing the CQL text.
54
- </p>
55
-
56
- <a id="AllExamples"></a>
57
-
58
- <h3>Table of examples</h3>
59
- <table class="examples" width="100%">
60
-
61
- <!--tr>
62
- <th>Model Name</th>
63
- <td></td>
64
- <td></td>
65
- <td></td>
66
- <th>ORM2 Diagrams</th-->
67
-
68
- <tr class="odd">
69
- <td class="title">
70
- <a id="Address" href="CQL/Address.cql">CQL</a>
71
- <span>Address</span>
72
- <div class="diagrams">
73
- <a href="images/Address.png">diagram</a>
74
- </div>
75
- </td>
76
- <td><a href="ruby/Address.rb">Ruby</a></td>
77
- <td><a href="SQL/Address.sql">SQL</a></td>
78
- <td>
79
- </tr>
80
- <tr class="odd"><td colspan="5">
81
- Shows how the relational mapping algorithm makes the minimum number of tables
82
- <a href="norma/Address.orm">xml</a>
83
- </td></tr>
84
-
85
- <tr class="even">
86
- <td class="title">
87
- <a id="Blog" href="CQL/Blog.cql">CQL</a>
88
- <span>Blog</span>
89
- <div class="diagrams">
90
- <a href="images/Blog.png">diagram</a>
91
- </div>
92
- </td>
93
- <td><a href="ruby/Blog.rb">Ruby</a></td>
94
- <td><a href="SQL/Blog.sql">SQL</a></td>
95
- <td>
96
- </tr>
97
- <tr class="even"><td colspan="5">
98
- The Blog model supports a hierarchy of topics, Posts by Authors, each Post
99
- consisting of a series of styled Paragraphs. Comments may be made on individual
100
- Paragraphs. <a href="norma/Blog.orm">xml</a>
101
- </td></tr>
102
-
103
- <tr class="odd">
104
- <td class="title">
105
- <a id="CompanyDirectorEmployee" href="CQL/CompanyDirectorEmployee.cql">CQL</a>
106
- <span>CompanyDirectorEmployee</span>
107
- <div class="diagrams">
108
- <a href="images/CompanyDirectorEmployee.png">diagram</a>
109
- </div>
110
- </td>
111
- <td><a href="ruby/CompanyDirectorEmployee.rb">Ruby</a></td>
112
- <td><a href="SQL/CompanyDirectorEmployee.sql">SQL</a></td>
113
- <td>
114
- </tr>
115
- <tr class="odd"><td colspan="5">
116
- This model shows the relationships of a person to a company of which they are a director or employee. <a href="norma/CompanyDirectorEmployee.orm">xml</a>
117
- </td></tr>
118
-
119
- <tr class="even">
120
- <td class="title">
121
- <a id="Death" href="CQL/Death.cql">CQL</a>
122
- <span>Death</span>
123
- <div class="diagrams">
124
- <a href="images/Death.png">diagram</a>
125
- </div>
126
- </td>
127
- <td><a href="ruby/Death.rb">Ruby</a></td>
128
- <td><a href="SQL/Death.sql">SQL</a></td>
129
- <td>
130
- </tr>
131
- <tr class="even"><td colspan="5">
132
- This model shows a objectified unary fact type. <a href="norma/Death.orm">xml</a>
133
- </td></tr>
134
-
135
- <tr class="odd">
136
- <td class="title">
137
- <a id="Genealogy" href="CQL/Genealogy.cql">CQL</a>
138
- <span>Genealogy</span>
139
- <div class="diagrams">
140
- <a href="images/Genealogy.png">diagram</a>
141
- </div>
142
- </td>
143
- <td><a href="ruby/Genealogy.rb">Ruby</a></td>
144
- <td><a href="SQL/Genealogy.sql">SQL</a></td>
145
- <td>
146
- </tr>
147
- <tr class="odd"><td colspan="5">
148
- An event-based model for Genealogy which allows for different versions of the same fact
149
- to be claimed by different sources, for use in reconciling contradictory information. <a href="norma/Genealogy.orm">xml</a>
150
- </td></tr>
151
-
152
- <tr class="even">
153
- <td class="title">
154
- <a id="Insurance" href="CQL/Insurance.cql">CQL</a>
155
- <span>Insurance</span>
156
- <div class="diagrams">
157
- <a href="images/Insurance/Insurance.png">Insurance</a>
158
- <a href="images/Insurance/Person.png">Person</a>
159
- <a href="images/Insurance/Policy.png">Policy</a>
160
- <a href="images/Insurance/Claim.png">Claim</a>
161
- <a href="images/Insurance/VehicleIncident.png">VehicleIncident</a>
162
- <a href="images/Insurance/Related.png">Related</a>
163
- </div>
164
- </td>
165
- <td><a href="ruby/Insurance.rb">Ruby</a></td>
166
- <td><a href="SQL/Insurance.sql">SQL</a></td>
167
- <td></td>
168
- </tr>
169
- <tr class="even"><td colspan="5">
170
- A partial model for an insurance company's claims management, extended into automotive insurance claims
171
- </td></tr>
172
-
173
- <tr class="odd">
174
- <td class="title">
175
- <a id="JoinEquality" href="CQL/JoinEquality.cql">CQL</a>
176
- <span>JoinEquality</span>
177
- <div class="diagrams">
178
- <a href="images/JoinEquality.png">diagram</a>
179
- </div>
180
- </td>
181
- <td><a href="ruby/JoinEquality.rb">Ruby</a></td>
182
- <td><a href="SQL/JoinEquality.sql">SQL</a></td>
183
- <td>
184
- </tr>
185
- <tr class="odd"><td colspan="5">
186
- An example of a join equality constraint. The highlighted constraint requires that
187
- tickets issued for an event are for a seat at the venue where that event will be held. <a href="norma/JoinEquality.orm">xml</a>
188
- </td></tr>
189
-
190
- <tr class="even">
191
- <td class="title">
192
- <a id="Marriage" href="CQL/Marriage.cql">CQL</a>
193
- <span>Marriage</span>
194
- <div class="diagrams">
195
- <a href="images/Marriage.png">diagram</a>
196
- </div>
197
- </td>
198
- <td><a href="ruby/Marriage.rb">Ruby</a></td>
199
- <td><a href="SQL/Marriage.sql">SQL</a></td>
200
- <td>
201
- </tr>
202
- <tr class="even"><td colspan="5">
203
- This shows a conventional model of marriage, to demonstrate the relational mapping (view the SQL). <a href="norma/Marriage.orm">xml</a>
204
- </td></tr>
205
-
206
- <tr class="odd">
207
- <td class="title">
208
- <a id="Metamodel" href="CQL/Metamodel.cql">CQL</a>
209
- <span>Metamodel</span>
210
- <div class="diagrams">
211
- <a href="images/Metamodel/Objects.png">Objects</a>
212
- <a href="images/Metamodel/Terms.png">Terms</a>
213
- <a href="images/Metamodel/ValueTypes.png">ValueTypes</a>
214
- <a href="images/Metamodel/Constraints.png">Constraints</a>
215
- <a href="images/Metamodel/Units.png">Units</a>
216
- <a href="images/Metamodel/Joins.png">Joins</a>
217
- <a href="images/Metamodel/ValueTypes.png">ValueTypes</a>
218
- <a href="images/Metamodel/Populations.png">Populations</a>
219
- <a href="images/Metamodel/Context.png">Context</a>
220
- <a href="images/Metamodel/Diagrams.png">Diagrams</a>
221
- </div>
222
- </td>
223
- <td><a href="ruby/Metamodel.rb">Ruby</a></td>
224
- <td><a href="SQL/Metamodel.sql">SQL</a></td>
225
- <td>
226
- </tr>
227
- <tr class="odd"><td colspan="5">
228
- This is the metamodel of ActiveFacts itself.
229
- The generated Ruby code provides the intermediate representation for the compiler!
230
- <br>
231
- <br>
232
- The Metamodel encodes the meaning of an ORM2 or CQL model. All features of the
233
- ORM2 and CQL languages have a representation here, as well as a few CQL features
234
- that haven't yet been implemented yet.
235
- </td></tr>
236
-
237
- <tr class="even">
238
- <td class="title">
239
- <a id="MultiInheritance" href="CQL/MultiInheritance.cql">CQL</a>
240
- <span>MultiInheritance</span>
241
- <div class="diagrams">
242
- <a href="images/MultiInheritance.png">diagram</a>
243
- </div>
244
- </td>
245
- <td><a href="ruby/MultiInheritance.rb">Ruby</a></td>
246
- <td><a href="SQL/MultiInheritance.sql">SQL</a></td>
247
- <td>
248
- </tr>
249
- <tr class="even"><td colspan="5">
250
- An example of multiple inheritance. The solid subtype connectors show the identification
251
- path (for example, an AustralianEmployee is identified by his/her EmployeeID). <a href="norma/MultiInheritance.orm">xml</a>
252
- </td></tr>
253
-
254
- <tr class="odd">
255
- <td class="title">
256
- <a id="OilSupply" href="CQL/OilSupply.cql">CQL</a>
257
- <span>OilSupply</span>
258
- <div class="diagrams">
259
- <a href="images/OilSupply.png">diagram</a><br>
260
- </div>
261
- </td>
262
- <td><a href="ruby/OilSupply.rb">Ruby</a></td>
263
- <td><a href="SQL/OilSupply.sql">SQL</a></td>
264
- <td>
265
- </tr>
266
- <tr class="odd"><td colspan="5">
267
- A model of the supply and demand for refined oil.
268
- A populated database can be used to optimise profitability by minimising transport costs,
269
- maximise supply by allowing substitution of compatible products (with compatibility depending on season)
270
- and also to predict shortages. <a href="norma/OilSupply.orm">xml</a>
271
- </td></tr>
272
-
273
- <tr class="even">
274
- <td class="title">
275
- <a id="Orienteering" href="CQL/Orienteering.cql">CQL</a>
276
- <span>Orienteering</span>
277
- <div class="diagrams">
278
- <a href="images/Orienteering/Administration.png">Administration</a>
279
- <a href="images/Orienteering/Registration.png">Registration</a>
280
- <a href="images/Orienteering/Scoring.png">Scoring</a>
281
- </div>
282
- </td>
283
- <td><a href="ruby/Orienteering.rb">Ruby</a></td>
284
- <td><a href="SQL/Orienteering.sql">SQL</a></td>
285
- <td>
286
- </tr>
287
- <tr class="even"><td colspan="5">
288
- A model for the sport of Orienteering, broken into three diagrams. <a href="norma/Orienteering.orm">xml</a>
289
- </td></tr>
290
-
291
- <tr class="odd">
292
- <td class="title">
293
- <a id="OrienteeringER" href="CQL/OrienteeringER.cql">CQL</a>
294
- <span>OrienteeringER</span>
295
- <div class="diagrams">
296
- <a href="images/OrienteeringER.png">diagram</a>
297
- </div>
298
- </td>
299
- <td><a href="ruby/OrienteeringER.rb">Ruby</a></td>
300
- <td><a href="SQL/OrienteeringER.sql">SQL</a></td>
301
- <td>
302
- </tr>
303
- <tr class="odd"><td colspan="5">
304
- This is an illegal ORM2 model, for illustrative purposes. It contains a compound fact type. <a href="norma/OrienteeringER.orm">xml</a>
305
- </td></tr>
306
-
307
- <tr class="even">
308
- <td class="title">
309
- <a id="PersonPlaysGame" href="CQL/PersonPlaysGame.cql">CQL</a>
310
- <span>PersonPlaysGame</span>
311
- <div class="diagrams">
312
- <a href="images/PersonPlaysGame.png">diagram</a>
313
- </div>
314
- </td>
315
- <td><a href="ruby/PersonPlaysGame.rb">Ruby</a></td>
316
- <td><a href="SQL/PersonPlaysGame.sql">SQL</a></td>
317
- <td>
318
- </tr>
319
- <tr class="even"><td colspan="5">
320
- Perhaps the simplest possible model, which maps to a single table. <a href="norma/PersonPlaysGame.orm">xml</a>
321
- </td></tr>
322
-
323
- <tr class="odd">
324
- <td class="title">
325
- <a id="RedundantDependency" href="CQL/RedundantDependency.cql">CQL</a>
326
- <span>RedundantDependency</span>
327
- <div class="diagrams">
328
- <a href="images/RedundantDependency.png">diagram</a>
329
- </div>
330
- </td>
331
- <td><a href="ruby/RedundantDependency.rb">Ruby</a></td>
332
- <td><a href="SQL/RedundantDependency.sql">SQL</a></td>
333
- <td>
334
- </tr>
335
- <tr class="odd"><td colspan="5">
336
- This model illustrates an outstanding problem in some fact-oriented modelling
337
- tools, including ActiveFacts. The problem is that the Address table contains
338
- two copies of the same value, StateOrProvinceId. <a href="norma/RedundantDependency.orm">xml</a>
339
- </td></tr>
340
-
341
- <tr class="even">
342
- <td class="title">
343
- <a id="SchoolActivities" href="CQL/SchoolActivities.cql">CQL</a>
344
- <span>SchoolActivities</span>
345
- <div class="diagrams">
346
- <a href="images/SchoolActivities.png">diagram</a>
347
- </div>
348
- </td>
349
- <td><a href="ruby/SchoolActivities.rb">Ruby</a></td>
350
- <td><a href="SQL/SchoolActivities.sql">SQL</a></td>
351
- <td>
352
- </tr>
353
- <tr class="even"><td colspan="5">
354
- This model represents students representing their school in school-sanctioned activities.
355
- It includes the ternary StudentParticipation <em>Fact Type</em>, which represents a student's
356
- participation in a school-sanctioned activity.
357
- The model has constraints that allow a given Student to participate only in a given
358
- Activity for a single School, only representing the School in which they're enrolled, and
359
- only if the School sanctions that activity. <a href="norma/SchoolActivities.orm">xml</a>
360
- </td></tr>
361
-
362
- <tr class="odd">
363
- <td class="title">
364
- <a id="Warehousing" href="CQL/Warehousing.cql">CQL</a>
365
- <span>Warehousing</span>
366
- <div class="diagrams">
367
- <a href="images/Warehousing.png">diagram</a>
368
- </div>
369
- </td>
370
- <td><a href="ruby/Warehousing.rb">Ruby</a></td>
371
- <td><a href="SQL/Warehousing.sql">SQL</a></td>
372
- <td>
373
- </tr>
374
- <tr class="odd"><td colspan="5">
375
- Based on a classic model of warehousing, it records stock levels for every product
376
- in each bin in every warehouse, and allows incoming and outgoing products to be
377
- allocated to be allocated to orders, including requests for transfers between
378
- warehouses. An order does not have to be shipped in a single shipment, but each
379
- item must be checked off for each shipment. <a href="norma/Warehousing.orm">xml</a>
380
- </td></tr>
381
-
382
- <tr class="even">
383
- <td class="title">
384
- <a id="Unit" href="unit.cql">CQL</a>
385
- <span>Unit conversions</span>
386
- </td>
387
- <td></td>
388
- <td></td>
389
- <td>
390
- </tr>
391
- <tr class="even"><td colspan="5">
392
- This CQL file contains an extensive library of fundamental units and unit conversions.
393
- These definitions can be used with your value types, so that queries can convert values
394
- from any compatible units.
395
- </td></tr>
396
-
397
- <tr class="odd">
398
- <td class="title">
399
- <a id="WindowInRoomInBldg" href="CQL/WindowInRoomInBldg.cql">CQL</a>
400
- <span>WindowInRoomInBldg</span>
401
- <div class="diagrams">
402
- <a href="images/WindowInRoomInBldg.png">diagram</a>
403
- </div>
404
- </td>
405
- <td><a href="ruby/WindowInRoomInBldg.rb">Ruby</a></td>
406
- <td><a href="SQL/WindowInRoomInBldg.sql">SQL</a></td>
407
- <td>
408
- </tr>
409
- <tr class="odd"><td colspan="5">
410
- This model shows how object types can get absorbed into others for efficient storage.
411
- In this case, every window is in a wall, every wall in a room, and every room in a
412
- building - yet only one table is needed to store a record of all windows. Try adding
413
- further properties to a room, and see what happens to the relational form! <a href="norma/WindowInRoomInBldg.orm">xml</a>
414
- </td></tr>
415
-
416
- </table>
417
-
418
- </div>
419
-
420
- <!--#include virtual="/footer.html" -->
@@ -1,327 +0,0 @@
1
- <!--#include virtual="/header.html" -->
2
- <!--#include virtual="navbar.html" -->
3
-
4
- <link rel="stylesheet" href="../css/offline.css" media="screen" type="text/css" />
5
- <link rel="stylesheet" href="../css/print.css" media="print" type="text/css" />
6
-
7
- <div id="top" class="content">
8
- <h2>Introduction to Object Role Modeling</h2>
9
- <p class="offline" ><font size="-1">Copyright (c) 2007 Clifford Heath.</font></p>
10
-
11
- <div class="localnav offline noprint">
12
- <a href="#top"><strong>Example Models</strong></a><br/>
13
- <a href="#CompanyDirectorEmployee"> Company </a><br/>
14
- <a href="#SchoolActivities"> School Activities </a><br/>
15
- <a href="#Death"> Death </a><br/>
16
- <a href="#Address"> Address</a><br/>
17
- <a href="#Orienteering"> Orienteering </a><br/>
18
- <a href="#AllExamples"> Table of all examples </a><br/>
19
- </div>
20
-
21
- <p> Congratulations, you're just a few minutes away from knowing a more
22
- agile way to design good database schemas. These models were created in ORM2
23
- using <a href="http://www.ormfoundation.org/files/">NORMA</a>.
24
- ORM2 terminology is <em>emphasised</em> on first use. Although the CQL here
25
- was generated from the ORM2, you can produce the same effect by writing it
26
- yourself.
27
- </p>
28
-
29
- <a name="CompanyDirectorEmployee"></a>
30
- <h3>CompanyDirectorEmployee</h3>
31
- <p>This model shows the some of the relationships of a person to a company of
32
- which they are a director or employee.
33
- </p>
34
-
35
- <table class="examples" width="100%">
36
- <tr>
37
- <td style='width:25%; border:0;'>View the generated:</td>
38
- <td><a href="CQL/CompanyDirectorEmployee.cql">CQL</a></td>
39
- <td><a href="ruby/CompanyDirectorEmployee.rb">Ruby</a></td>
40
- <td><a href="SQL/CompanyDirectorEmployee.sql">SQL</a></td>
41
- </tr>
42
- </table>
43
-
44
- <p><center>
45
- <img src="images/CompanyDirectorEmployee.png" width="700" height="420" class="hangleft"></p>
46
- </center>
47
- </p>
48
-
49
- <p>This model includes examples of the features of ORM2 you'll be seeing most often.</p>
50
- <ul>
51
- <li><i>Entity Types</i> (<b>Person</b>, <b>Company</b>) and <i>Value Types</i>
52
- (Name, Date). Collectively, ActiveFacts calls them Concepts. Value types
53
- have a dashed outline.
54
- </li>
55
-
56
- <li>Entity <i>Identification schemes</i>: Person is identified by the pair
57
- of values (given-Name, family-Name), as indicated by the circle with two
58
- lines across it. Company is identified by a single CompanyName, but since
59
- this is a common pattern, it's included within the Company shape, which
60
- is called a <b>reference mode</b>. Every Entity Type must have some
61
- identification scheme or preferred identifier, which enables us to tell
62
- the instances apart.
63
- </li>
64
-
65
- <li><i>Subtype:</i> <b>Employee</b> and <b>Manager</b> are subtypes.
66
- Employee has a dashed arrow, because it has its own identification scheme,
67
- it doesn't use Persons's scheme. An EntityType may have multiple supertypes,
68
- and an instance may play any role of its supertypes (so we can record the
69
- Birth-Date of an Employee, for example).
70
- </li>
71
-
72
- <li><i>Fact Types</i> define relationships between concepts. They're displayed
73
- as a series of one or more <i>Role</i> boxes. For example, the fact type
74
- "Person has given-Name" has two roles, played by Person and Name.
75
- The <b>unary fact type</b> <i>Meeting is board meeting</i> indicates a
76
- true/false condition with respect to a meeting.
77
- </li>
78
-
79
- <li><i>Objectified Fact Type:</i> <b>Directorship</b> and <b>Meeting</b> are
80
- fact types that are also entities, and thus can play other roles, such as
81
- the role of Directorship in "Directorship began on appointment-Date".
82
- </li>
83
-
84
- <li><i>Fact Readings</i> are displayed as text under each fact type. A fact
85
- type may have many readings, though only the preferred one is shown on the
86
- diagram. Binary fact types may display a reading for each direction. An
87
- arrow is displayed if a single reading is to be read in the opposite order
88
- from the obvious one.
89
- </li>
90
-
91
- <li><i>Uniqueness constraints</i>: The horizontal lines above the fact types
92
- are uniqueness constraints (UC). A UC covering a single role allows that
93
- role's player to occur only once all the instances of that fact type (what
94
- we call the <b>population</b> of that fact type). A UC that covers two or
95
- more roles allows any combination of those players, but only once for each
96
- combination. An </b>external</b> UC may connect to roles in more than one
97
- fact type, and is shown as a circle with a line across it. If any of the
98
- UC lines is doubles, that UC acts as a preferred identifier for the indicated
99
- entity type.
100
- </li>
101
-
102
- <li><i>Mandatory constraint</i>: The heavy dot on some role connectors (like
103
- the one on the Company role box of Director) is a mandatory constraint that
104
- requires every company to have at least one director. A mandatory constraint
105
- may also be shown as a hollow dot, which says <i>should</i>, rather than
106
- <i>must</i>.
107
- </li>
108
-
109
- <li><i>External Mandatory constraint</i>: The circle containing a crossed dot
110
- which is joined to "is ceo" and "Employee is supervised by Manager" is a
111
- mandatory exclusion constraint. The cross (X) indicates exclusion (only one)
112
- and the dot indicates mandatory (at least one). Both types may also occur
113
- separately.
114
- </li>
115
-
116
- <li><i>Ring constraint</i>: A Ring constraint is attached to the "Employee is
117
- supervised by Manager". This one is acyclic, indicating that an Employee
118
- may not supervise themselves, or anyone who supervises them, and so on.
119
- There are a number of other types of ring constraints.
120
- </li>
121
-
122
- <li><i>Role Value Constraint</i>: The Date value recorded for a person's birth
123
- date may not be before the year 1900. Other Date values don't have this
124
- same restriction.
125
- </li>
126
-
127
- </ul>
128
-
129
- <br clear="all">
130
- <a name="SchoolActivities">
131
- </a>
132
- <h3>SchoolActivities
133
- </h3>
134
- <p>This model represents students representing their school in school-sanctioned activities.
135
- </p>
136
-
137
- <p align="center"><img src="images/SchoolActivities.png"></p>
138
-
139
- <p>
140
- The model has three interesting constraints:
141
- <dl>
142
- <dt> Uniqueness over <em>Student represents School in Activity</em>:</dt>
143
- <dd> Allows a given Student may only participate in a given Activity for a single School</dd>
144
- <dt> <b>Subset</b> from Participation to Enrollment</dt>
145
- <dd> Only for the School in which they're enrolled</dd>
146
- <dt> <b>Subset</b> from Participation to Sanctions</dt>
147
- <dd> Only if the School sanctions that activity.</dd>
148
- </p>
149
-
150
- <p> The rules of <em>elementarity</em> require that every fact type having N roles has
151
- a uniqueness constraint over either N or N-1 roles, and never over fewer roles.
152
- This is satisfied here by the StudentParticipation having a uniqueness constraint
153
- over two of its three roles.
154
- </p>
155
-
156
- <p>
157
- The subset constraints work like this. The student is enrolled in exactly one school,
158
- and the set of (School, Student) pairs is a superset of the (School, Student) pair
159
- inside the StudentParticipation ternary. In simple terms, this requires that each
160
- student who participates in some activity may only do so as a representative of the
161
- school in which they're enrolled, and not for any other school. The other subset
162
- constraint requires that such participation may only occur for an activity that is
163
- sanctioned by that school. The direction of the subset arrow is consistent with the
164
- arrows used in sub-typing, as shown in the next case.
165
- </p>
166
-
167
- <br clear="all">
168
- <a name="Death"></a>
169
- <h3>Death</h3>
170
- <img src="images/Death.png" align="right">
171
- This example is more a curiosity than anything else, serving to illustrate a case
172
- that you might not otherwise think was possible. Person may play a unary role in
173
- the fact type &quot;is dead&quot;. If they are in fact dead, we might wish to
174
- record some facts about the event of their death, so we nest (objectify) the
175
- &quot;is dead&quot; fact type as a new entity, Death. This allows us to
176
- associate their death with a value indicating the cause of death. The uniqueness
177
- constraint requires that we record only one cause of death.
178
- <p>
179
-
180
- <br clear="all">
181
- <a name="Address">
182
- </a>
183
- <h3>
184
- Address
185
- </h3>
186
-
187
- <p>The Address model shows how a mass of fine semantic detail can be turned into
188
- an efficient relational database structure, through the miracle of <em>absorption</em>.
189
- </p>
190
-
191
- <table class="examples" width="100%">
192
- <tr>
193
- <td style='width:25%; border:0;'>View the generated:</td>
194
- <td><a href="CQL/Address.cql">CQL</a></td>
195
- <td><a href="ruby/Address.rb">Ruby</a></td>
196
- <td><a href="SQL/Address.sql">SQL</a></td>
197
- </tr>
198
- </table>
199
- </p>
200
-
201
- <p align="center"><img src="images/Address.png" class="hangleft">
202
-
203
- <p>Note that the preferred identifier for Street covers all its functional roles.
204
- Essentially that means that whereever we have a Street, all the attributes of that
205
- street must be provided; so we can include them in more than one table without
206
- breaking the relational <a href="http://en.wikipedia.org/wiki/Third_normal_form">Third
207
- Normal Form</a>, which would introduce unsafe duplication.
208
-
209
- </p><p>
210
- The same thing pertains for Address, so we can have an Address in both the Company
211
- and Person tables without breaking normalisation. Here's the generated SQL created
212
- by <em>afgen</em>:
213
-
214
- </p> <p>
215
- <img src="images/Address.SQL.png" align="left">
216
- </p>
217
- <br clear="all">
218
-
219
- <p>Note also that the SQL doesn't enforce the uniqueness constraint requiring
220
- that each Address occurs once only. There's no need to. Each Address is
221
- identified by its roles, but more than one person may live at the same address,
222
- and a company might have its HQ there too. If you want all the distinct addresses,
223
- you can write an SQL UNION query for that.
224
- </p>
225
-
226
- <p>If you want an Address table anyhow, you can mark it as <em>independent</em>,
227
- which is an instruction to the absorption process that an instance of this entity
228
- type might exist apart from any other roles it might play. Independent entity types
229
- are shown in ORM2 as having an exclamation point <b>!</b> after their name. In
230
- order to represent an independent entity type in SQL, a separate table is always
231
- needed.
232
- </p>
233
-
234
- <p> If you were to add a functional role to Address that's not part of its
235
- identifier, the rules of normalisation gazump absorption and Address will become
236
- an independent table. In that case, Company and Person would have each a large
237
- multi-part foreign key into the new Address table, so it might be preferable to
238
- introduce a <i>surrogate key</i> in the form of a database-allocated unique integer
239
- into the address entity, and mark that key as the preferred identifier instead.
240
- This can be done with <em>minimal</em> change to the semantic model, so any queries
241
- you have will probably still <b>just work</b> - this is a key advantage of the
242
- semantic approach.
243
- </p>
244
-
245
- <p>
246
- Note that the absorption process must know <b>all</b> the entity types, fact types,
247
- and constraints for the model. If you add a single fact type or change a constraint,
248
- that might require that some concepts are represented in new tables, or different ones,
249
- and these changes can <b>cascade</b>, so that a small change in the conceptual model
250
- requires a large database migration. If you've written your program using the
251
- Constellation API, you'll have <em>minimal rework</em>.
252
- </p>
253
-
254
- <br clear="all">
255
- <h3>
256
- <a name="Orienteering">
257
- </a>
258
- Orienteering
259
- </h3>
260
- <p>Here's a three-part model of a system for the sport of Orienteering. The
261
- three parts cover administration, registration and scoring respectively, which
262
- also happens to map areas of interest to folk in different roles. Any feature
263
- may show on more than one diagram, and the ORM2 rules don't indicate that such
264
- an element has a special affinity with any diagram on which it appears.
265
- Concepts that appear in more than one place are shown with a drop-shadow. The
266
- diagrams are presented without much comment, and after that, the absorbed
267
- (compound) form is shown as an entity-relationship diagram. </p>
268
-
269
- <a name="Administration"></a>
270
- <h3>
271
- Administration
272
- </h3>
273
- <p align="center"><img src="images/Orienteering/Administration.png">
274
- </p>
275
-
276
- <p>
277
- A couple of new features are shown here. <i>Number</i> has a <b>Value Constraint</b>,
278
- which is similar to the role value constraints we saw before, except it applies
279
- to all <i>Number</i>s.
280
- </p>
281
-
282
- <p>Also here you'll see an external mandatory constraint without an exclusive
283
- cross. This one requires that an event is either part of a series, or has a name,
284
- or <b>both</b>. If and only if the event is part of a series, it must also have a
285
- number in that series - this is shown by the <b>equality constraint</b>, a
286
- circle with an = sign in it. </p>
287
- <br clear="all">
288
- </p>
289
-
290
- <a name="Registration"></a>
291
- <h3>
292
- Registration
293
- </h3>
294
-
295
- <p align="center"><img src="images/Orienteering/Registration.png"></p>
296
-
297
- <br clear="all">
298
- <a name="Scoring"></a>
299
- </p>
300
- <h3>
301
- Scoring
302
- </h3>
303
-
304
- <p align="center"><img src="images/Orienteering/Scoring.png">
305
- <table class="examples" width="100%">
306
- <tr>
307
- <td style='width:25%; border:0;'>View the generated:</td>
308
- <td><a href="CQL/Orienteering.cql">CQL</a></td>
309
- <td><a href="ruby/Orienteering.rb">Ruby</a></td>
310
- <td><a href="SQL/Orienteering.sql">SQL</a></td>
311
- </tr>
312
- </table>
313
- </p>
314
-
315
- <p>This model also shows the resultant score for a given Entrant's
316
- Entry to a given Event. This value will be computed from the times
317
- of their visits to punches during the event, according to a scoring
318
- method as advised. The asterisks indicate that the role value is
319
- derived from other values in the model, or that some values may
320
- be derived and others now.
321
-
322
- <br clear="all">
323
- </p>
324
-
325
- </div>
326
-
327
- <!--#include virtual="/footer.html" -->