activefacts-examples 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (262) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +10 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +22 -0
  8. data/Rakefile +6 -0
  9. data/activefacts-examples.gemspec +26 -0
  10. data/cql/Address.cql +44 -0
  11. data/cql/Astronomy.cql +35 -0
  12. data/cql/Blog.cql +54 -0
  13. data/cql/CinemaBookings.cql +64 -0
  14. data/cql/CinemaTickets.cql +127 -0
  15. data/cql/CompanyDirectorEmployee.cql +56 -0
  16. data/cql/Death.cql +17 -0
  17. data/cql/Diplomacy.cql +48 -0
  18. data/cql/Genealogy.cql +98 -0
  19. data/cql/Health.cql +78 -0
  20. data/cql/Insurance.cql +320 -0
  21. data/cql/Marriage.cql +18 -0
  22. data/cql/Metamodel.cql +567 -0
  23. data/cql/Monogamy.cql +24 -0
  24. data/cql/MultiInheritance.cql +22 -0
  25. data/cql/MultipleSubtyping.cql +30 -0
  26. data/cql/NonRoleId.cql +14 -0
  27. data/cql/OddIdentifier.cql +18 -0
  28. data/cql/OilSupply.cql +53 -0
  29. data/cql/OneRoleNesting.cql +38 -0
  30. data/cql/OneToOnes.cql +17 -0
  31. data/cql/Orienteering.cql +111 -0
  32. data/cql/PartyModel.cql +38 -0
  33. data/cql/PersonPlaysGame.cql +18 -0
  34. data/cql/RedundantDependency.cql +34 -0
  35. data/cql/SchoolActivities.cql +33 -0
  36. data/cql/SeparateSubtype.cql +30 -0
  37. data/cql/ServiceDirector.cql +276 -0
  38. data/cql/SimplestUnary.cql +12 -0
  39. data/cql/Supervision.cql +34 -0
  40. data/cql/VenueSeating.cql +45 -0
  41. data/cql/WaiterTips.cql +33 -0
  42. data/cql/Warehousing.cql +101 -0
  43. data/cql/WindowInRoomInBldg.cql +28 -0
  44. data/cql/unit.cql +474 -0
  45. data/diagrams/json/Address.json +41 -0
  46. data/diagrams/json/Astronomy.json +31 -0
  47. data/diagrams/json/Blog.json +46 -0
  48. data/diagrams/json/CinemaBookings.json +53 -0
  49. data/diagrams/json/CinemaTickets.json +101 -0
  50. data/diagrams/json/CompanyDirectorEmployee.json +44 -0
  51. data/diagrams/json/Death.json +20 -0
  52. data/diagrams/json/Diplomacy.json +34 -0
  53. data/diagrams/json/Genealogy.json +78 -0
  54. data/diagrams/json/Insurance.json +259 -0
  55. data/diagrams/json/Marriage.json +21 -0
  56. data/diagrams/json/Metamodel.json +318 -0
  57. data/diagrams/json/Monogamy.json +22 -0
  58. data/diagrams/json/MultiInheritance.json +25 -0
  59. data/diagrams/json/MultipleSubtyping.json +22 -0
  60. data/diagrams/json/OilSupply.json +49 -0
  61. data/diagrams/json/OneRoleNesting.json +37 -0
  62. data/diagrams/json/Orienteering.json +94 -0
  63. data/diagrams/json/PersonPlaysGame.json +22 -0
  64. data/diagrams/json/RedundantDependency.json +33 -0
  65. data/diagrams/json/SchoolActivities.json +28 -0
  66. data/diagrams/json/SeparateSubtype.json +29 -0
  67. data/diagrams/json/SimplestUnary.json +15 -0
  68. data/diagrams/json/Supervision.json +27 -0
  69. data/diagrams/json/VenueSeating.json +40 -0
  70. data/diagrams/json/WaiterTips.json +29 -0
  71. data/diagrams/json/Warehousing.json +86 -0
  72. data/diagrams/json/WindowInRoomInBldg.json +31 -0
  73. data/images/Address.SQL.png +0 -0
  74. data/images/Address.png +0 -0
  75. data/images/Blog.png +0 -0
  76. data/images/CinemaBookings.png +0 -0
  77. data/images/CinemaTickets.png +0 -0
  78. data/images/CompanyDirectorEmployee.png +0 -0
  79. data/images/Death.png +0 -0
  80. data/images/Diplomacy.png +0 -0
  81. data/images/DumpMetamodel.bat +2 -0
  82. data/images/Genealogy.png +0 -0
  83. data/images/Insurance/Claim.png +0 -0
  84. data/images/Insurance/Insurance.png +0 -0
  85. data/images/Insurance/Person.png +0 -0
  86. data/images/Insurance/Policy.png +0 -0
  87. data/images/Insurance/Related.png +0 -0
  88. data/images/Insurance/VehicleIncident.png +0 -0
  89. data/images/Marriage.png +0 -0
  90. data/images/Metamodel/Concepts.png +0 -0
  91. data/images/Metamodel/Constraints.png +0 -0
  92. data/images/Metamodel/ContextNote.png +0 -0
  93. data/images/Metamodel/Diagrams.png +0 -0
  94. data/images/Metamodel/Language.png +0 -0
  95. data/images/Metamodel/Legacy.png +0 -0
  96. data/images/Metamodel/Objects.png +0 -0
  97. data/images/Metamodel/Populations.png +0 -0
  98. data/images/Metamodel/Query.png +0 -0
  99. data/images/Metamodel/Units.png +0 -0
  100. data/images/Metamodel/ValueConstraints.png +0 -0
  101. data/images/Metamodel/ValueTypes.png +0 -0
  102. data/images/MetamodelER.bcp +1 -0
  103. data/images/MetamodelER.pdf +0 -0
  104. data/images/MultiInheritance.png +0 -0
  105. data/images/NorthwindER.png +0 -0
  106. data/images/OilSupply.png +0 -0
  107. data/images/Orienteering/Administration.png +0 -0
  108. data/images/Orienteering/Registration.png +0 -0
  109. data/images/Orienteering/Scoring.png +0 -0
  110. data/images/PersonPlaysGame.png +0 -0
  111. data/images/RedundantDependency.png +0 -0
  112. data/images/SchoolActivities.png +0 -0
  113. data/images/SeparateSubtype.png +0 -0
  114. data/images/SimplestUnary.png +0 -0
  115. data/images/Supervision.png +0 -0
  116. data/images/VenueSeating.png +0 -0
  117. data/images/WaiterTips.png +0 -0
  118. data/images/Warehousing.png +0 -0
  119. data/images/WindowInRoomInBldg.png +0 -0
  120. data/metadata/json/Astronomy.json +175 -0
  121. data/metadata/json/CinemaBookings.json +354 -0
  122. data/metadata/json/CinemaTickets.json +768 -0
  123. data/metadata/json/CompanyDirectorEmployee.json +270 -0
  124. data/metadata/json/Diplomacy.json +186 -0
  125. data/metadata/json/Metamodel.json +3214 -0
  126. data/metadata/json/OilSupply.json +411 -0
  127. data/metadata/json/SeparateSubtype.json +157 -0
  128. data/metadata/json/Supervision.json +128 -0
  129. data/metadata/json/VenueSeating.json +209 -0
  130. data/orm/.gitignore +11 -0
  131. data/orm/Address.orm +1268 -0
  132. data/orm/Astronomy.orm +925 -0
  133. data/orm/Blog.orm +1711 -0
  134. data/orm/CinemaBookings.orm +1998 -0
  135. data/orm/CinemaTickets.orm +5060 -0
  136. data/orm/CompanyDirectorEmployee.orm +2094 -0
  137. data/orm/Death.orm +386 -0
  138. data/orm/Diplomacy.orm +1478 -0
  139. data/orm/ExampleModels2010.csproj +764 -0
  140. data/orm/ExampleModels2010.sln +16 -0
  141. data/orm/Genealogy.orm +3209 -0
  142. data/orm/Health.orm +2407 -0
  143. data/orm/Insurance.orm +12727 -0
  144. data/orm/Marriage.orm +493 -0
  145. data/orm/Metamodel.orm +20998 -0
  146. data/orm/Monogamy.orm +328 -0
  147. data/orm/MultiInheritance.orm +537 -0
  148. data/orm/MultipleSubtyping.orm +347 -0
  149. data/orm/OilSupply.orm +2533 -0
  150. data/orm/OneRoleNesting.orm +1237 -0
  151. data/orm/Orienteering.orm +3976 -0
  152. data/orm/PersonPlaysGame.orm +426 -0
  153. data/orm/RedundantDependency.orm +844 -0
  154. data/orm/SchoolActivities.orm +961 -0
  155. data/orm/SeparateSubtype.orm +821 -0
  156. data/orm/SimplestUnary.orm +172 -0
  157. data/orm/Supervision.orm +734 -0
  158. data/orm/VenueSeating.orm +1289 -0
  159. data/orm/WaiterTips.orm +789 -0
  160. data/orm/Warehousing.orm +3792 -0
  161. data/orm/WindowInRoomInBldg.orm +772 -0
  162. data/rails/models/Astronomy.models +17 -0
  163. data/rails/models/CinemaBookings.models +123 -0
  164. data/rails/models/CinemaTickets.models +192 -0
  165. data/rails/models/Diplomacy.models +126 -0
  166. data/rails/models/Metamodel.models +894 -0
  167. data/rails/models/OneRoleNesting.models +18 -0
  168. data/rails/models/SeparateSubtype.models +49 -0
  169. data/rails/models/VenueSeating.models +70 -0
  170. data/rails/schema/Astronomy.schema.rb +25 -0
  171. data/rails/schema/CinemaBookings.schema.rb +78 -0
  172. data/rails/schema/CinemaTickets.schema.rb +132 -0
  173. data/rails/schema/Diplomacy.schema.rb +74 -0
  174. data/rails/schema/Metamodel.schema.rb +538 -0
  175. data/rails/schema/OneRoleNesting.rb +20 -0
  176. data/rails/schema/SeparateSubtype.schema.rb +35 -0
  177. data/rails/schema/VenueSeating.schema.rb +46 -0
  178. data/rails/schema/Warehousing.schema.rb +145 -0
  179. data/ruby/Address.rb +68 -0
  180. data/ruby/Astronomy.rb +55 -0
  181. data/ruby/Blog.rb +84 -0
  182. data/ruby/CinemaBookings.rb +109 -0
  183. data/ruby/CinemaTickets.rb +218 -0
  184. data/ruby/CompanyDirectorEmployee.rb +73 -0
  185. data/ruby/Death.rb +26 -0
  186. data/ruby/Diplomacy.rb +59 -0
  187. data/ruby/Genealogy.rb +173 -0
  188. data/ruby/Insurance.rb +562 -0
  189. data/ruby/Marriage.rb +21 -0
  190. data/ruby/Metamodel.rb +621 -0
  191. data/ruby/Monogamy.rb +27 -0
  192. data/ruby/MultiInheritance.rb +38 -0
  193. data/ruby/OilSupply.rb +112 -0
  194. data/ruby/OneRoleNesting.rb +66 -0
  195. data/ruby/Orienteering.rb +216 -0
  196. data/ruby/PersonPlaysGame.rb +31 -0
  197. data/ruby/RedundantDependency.rb +53 -0
  198. data/ruby/SchoolActivities.rb +49 -0
  199. data/ruby/SeparateSubtype.rb +46 -0
  200. data/ruby/SimplestUnary.rb +10 -0
  201. data/ruby/Supervision.rb +33 -0
  202. data/ruby/TwoValues.rb +14 -0
  203. data/ruby/VenueSeating.rb +64 -0
  204. data/ruby/WaiterTips.rb +49 -0
  205. data/ruby/Warehousing.rb +167 -0
  206. data/ruby/WindowInRoomInBldg.rb +45 -0
  207. data/sql/server/Address.sql +40 -0
  208. data/sql/server/Astronomy.sql +36 -0
  209. data/sql/server/Blog.sql +78 -0
  210. data/sql/server/CinemaBookings.sql +95 -0
  211. data/sql/server/CinemaTickets.sql +191 -0
  212. data/sql/server/CompanyDirectorEmployee.sql +104 -0
  213. data/sql/server/Death.sql +11 -0
  214. data/sql/server/Diplomacy.sql +66 -0
  215. data/sql/server/Genealogy.sql +138 -0
  216. data/sql/server/Health.sql +169 -0
  217. data/sql/server/Insurance.sql +484 -0
  218. data/sql/server/Marriage.sql +30 -0
  219. data/sql/server/Metamodel.sql +1000 -0
  220. data/sql/server/Monogamy.sql +20 -0
  221. data/sql/server/MultiInheritance.sql +27 -0
  222. data/sql/server/OilSupply.sql +105 -0
  223. data/sql/server/OneRoleNesting.sql +29 -0
  224. data/sql/server/Orienteering.sql +186 -0
  225. data/sql/server/PersonPlaysGame.sql +9 -0
  226. data/sql/server/RedundantDependency.sql +54 -0
  227. data/sql/server/SchoolActivities.sql +30 -0
  228. data/sql/server/SeparateSubtype.sql +33 -0
  229. data/sql/server/SimplestUnary.sql +9 -0
  230. data/sql/server/Supervision.sql +30 -0
  231. data/sql/server/VenueSeating.sql +54 -0
  232. data/sql/server/WaiterTips.sql +31 -0
  233. data/sql/server/Warehousing.sql +203 -0
  234. data/sql/server/WindowInRoomInBldg.sql +13 -0
  235. data/transform/surrogate/Address.absorption +2 -0
  236. data/transform/surrogate/Blog.absorption +5 -0
  237. data/transform/surrogate/CinemaBookings.absorption +7 -0
  238. data/transform/surrogate/CompanyDirectorEmployee.absorption +7 -0
  239. data/transform/surrogate/Death.absorption +1 -0
  240. data/transform/surrogate/Diplomacy-revised.absorption +6 -0
  241. data/transform/surrogate/Diplomacy.absorption +6 -0
  242. data/transform/surrogate/Genealogy.absorption +8 -0
  243. data/transform/surrogate/Insurance.absorption +18 -0
  244. data/transform/surrogate/Marriage.absorption +2 -0
  245. data/transform/surrogate/Metamodel.absorption +25 -0
  246. data/transform/surrogate/Monogamy.absorption +1 -0
  247. data/transform/surrogate/MultiInheritance.absorption +1 -0
  248. data/transform/surrogate/MultipleSubtyping.absorption +1 -0
  249. data/transform/surrogate/OilSupply.absorption +8 -0
  250. data/transform/surrogate/OneRoleNesting.absorption +1 -0
  251. data/transform/surrogate/Orienteering.absorption +11 -0
  252. data/transform/surrogate/PersonPlaysGame.absorption +1 -0
  253. data/transform/surrogate/RedundantDependency.absorption +3 -0
  254. data/transform/surrogate/SchoolActivities.absorption +3 -0
  255. data/transform/surrogate/SeparateSubtype.absorption +3 -0
  256. data/transform/surrogate/SimplestUnary.absorption +1 -0
  257. data/transform/surrogate/Supervision.absorption +2 -0
  258. data/transform/surrogate/WaiterTips.absorption +3 -0
  259. data/transform/surrogate/Warehousing.absorption +12 -0
  260. data/transform/surrogate/WindowInRoomInBldg.absorption +1 -0
  261. data/transform/surrogate/unit.absorption +0 -0
  262. metadata +374 -0
@@ -0,0 +1,49 @@
1
+ require 'activefacts/api'
2
+
3
+ module ::WaiterTips
4
+
5
+ class AUDValue < Money
6
+ value_type
7
+ one_to_one :amount # See Amount.aud_value
8
+ end
9
+
10
+ class MealId < AutoCounter
11
+ value_type
12
+ one_to_one :meal # See Meal.meal_id
13
+ end
14
+
15
+ class WaiterNr < SignedInteger
16
+ value_type :length => 32
17
+ one_to_one :waiter # See Waiter.waiter_nr
18
+ end
19
+
20
+ class Amount
21
+ identified_by :aud_value
22
+ one_to_one :aud_value, :class => AUDValue, :mandatory => true # See AUDValue.amount
23
+ end
24
+
25
+ class Meal
26
+ identified_by :meal_id
27
+ one_to_one :meal_id, :mandatory => true # See MealId.meal
28
+ end
29
+
30
+ class Waiter
31
+ identified_by :waiter_nr
32
+ one_to_one :waiter_nr, :mandatory => true # See WaiterNr.waiter
33
+ end
34
+
35
+ class WaiterTip
36
+ identified_by :waiter, :meal
37
+ has_one :amount, :mandatory => true # See Amount.all_waiter_tip
38
+ has_one :meal, :mandatory => true # See Meal.all_waiter_tip
39
+ has_one :waiter, :mandatory => true # See Waiter.all_waiter_tip
40
+ end
41
+
42
+ class Service
43
+ identified_by :waiter, :meal
44
+ has_one :meal, :mandatory => true # See Meal.all_service
45
+ has_one :waiter, :mandatory => true # See Waiter.all_service
46
+ has_one :amount # See Amount.all_service
47
+ end
48
+
49
+ end
@@ -0,0 +1,167 @@
1
+ require 'activefacts/api'
2
+
3
+ module ::Warehousing
4
+
5
+ class BinID < AutoCounter
6
+ value_type
7
+ one_to_one :bin # See Bin.bin_id
8
+ end
9
+
10
+ class DispatchID < AutoCounter
11
+ value_type
12
+ one_to_one :dispatch # See Dispatch.dispatch_id
13
+ end
14
+
15
+ class DispatchItemID < AutoCounter
16
+ value_type
17
+ one_to_one :dispatch_item # See DispatchItem.dispatch_item_id
18
+ end
19
+
20
+ class PartyID < AutoCounter
21
+ value_type
22
+ one_to_one :party # See Party.party_id
23
+ end
24
+
25
+ class ProductID < AutoCounter
26
+ value_type
27
+ one_to_one :product # See Product.product_id
28
+ end
29
+
30
+ class PurchaseOrderID < AutoCounter
31
+ value_type
32
+ one_to_one :purchase_order # See PurchaseOrder.purchase_order_id
33
+ end
34
+
35
+ class Quantity < UnsignedInteger
36
+ value_type :length => 32
37
+ end
38
+
39
+ class ReceiptID < AutoCounter
40
+ value_type
41
+ one_to_one :receipt # See Receipt.receipt_id
42
+ end
43
+
44
+ class ReceivedItemID < AutoCounter
45
+ value_type
46
+ one_to_one :received_item # See ReceivedItem.received_item_id
47
+ end
48
+
49
+ class SalesOrderID < AutoCounter
50
+ value_type
51
+ one_to_one :sales_order # See SalesOrder.sales_order_id
52
+ end
53
+
54
+ class TransferRequestID < AutoCounter
55
+ value_type
56
+ one_to_one :transfer_request # See TransferRequest.transfer_request_id
57
+ end
58
+
59
+ class WarehouseID < AutoCounter
60
+ value_type
61
+ one_to_one :warehouse # See Warehouse.warehouse_id
62
+ end
63
+
64
+ class Bin
65
+ identified_by :bin_id
66
+ one_to_one :bin_id, :class => BinID, :mandatory => true # See BinID.bin
67
+ has_one :product # See Product.all_bin
68
+ has_one :quantity, :mandatory => true # See Quantity.all_bin
69
+ has_one :warehouse # See Warehouse.all_bin
70
+ end
71
+
72
+ class Dispatch
73
+ identified_by :dispatch_id
74
+ one_to_one :dispatch_id, :class => DispatchID, :mandatory => true # See DispatchID.dispatch
75
+ end
76
+
77
+ class DispatchItem
78
+ identified_by :dispatch_item_id
79
+ has_one :dispatch # See Dispatch.all_dispatch_item
80
+ one_to_one :dispatch_item_id, :class => DispatchItemID, :mandatory => true # See DispatchItemID.dispatch_item
81
+ has_one :product, :mandatory => true # See Product.all_dispatch_item
82
+ has_one :quantity, :mandatory => true # See Quantity.all_dispatch_item
83
+ has_one :sales_order_item # See SalesOrderItem.all_dispatch_item
84
+ has_one :transfer_request # See TransferRequest.all_dispatch_item
85
+ end
86
+
87
+ class Party
88
+ identified_by :party_id
89
+ one_to_one :party_id, :class => PartyID, :mandatory => true # See PartyID.party
90
+ end
91
+
92
+ class Product
93
+ identified_by :product_id
94
+ one_to_one :product_id, :class => ProductID, :mandatory => true # See ProductID.product
95
+ end
96
+
97
+ class PurchaseOrder
98
+ identified_by :purchase_order_id
99
+ one_to_one :purchase_order_id, :class => PurchaseOrderID, :mandatory => true # See PurchaseOrderID.purchase_order
100
+ has_one :supplier, :mandatory => true # See Supplier.all_purchase_order
101
+ has_one :warehouse, :mandatory => true # See Warehouse.all_purchase_order
102
+ end
103
+
104
+ class PurchaseOrderItem
105
+ identified_by :purchase_order, :product
106
+ has_one :product, :mandatory => true # See Product.all_purchase_order_item
107
+ has_one :purchase_order, :mandatory => true # See PurchaseOrder.all_purchase_order_item
108
+ has_one :quantity, :mandatory => true # See Quantity.all_purchase_order_item
109
+ end
110
+
111
+ class Receipt
112
+ identified_by :receipt_id
113
+ one_to_one :receipt_id, :class => ReceiptID, :mandatory => true # See ReceiptID.receipt
114
+ end
115
+
116
+ class ReceivedItem
117
+ identified_by :received_item_id
118
+ has_one :product, :mandatory => true # See Product.all_received_item
119
+ has_one :purchase_order_item # See PurchaseOrderItem.all_received_item
120
+ has_one :quantity, :mandatory => true # See Quantity.all_received_item
121
+ has_one :receipt # See Receipt.all_received_item
122
+ one_to_one :received_item_id, :class => ReceivedItemID, :mandatory => true # See ReceivedItemID.received_item
123
+ has_one :transfer_request # See TransferRequest.all_received_item
124
+ end
125
+
126
+ class SalesOrder
127
+ identified_by :sales_order_id
128
+ has_one :customer, :mandatory => true # See Customer.all_sales_order
129
+ one_to_one :sales_order_id, :class => SalesOrderID, :mandatory => true # See SalesOrderID.sales_order
130
+ has_one :warehouse, :mandatory => true # See Warehouse.all_sales_order
131
+ end
132
+
133
+ class SalesOrderItem
134
+ identified_by :sales_order, :product
135
+ has_one :product, :mandatory => true # See Product.all_sales_order_item
136
+ has_one :quantity, :mandatory => true # See Quantity.all_sales_order_item
137
+ has_one :sales_order, :mandatory => true # See SalesOrder.all_sales_order_item
138
+ end
139
+
140
+ class Supplier < Party
141
+ end
142
+
143
+ class TransferRequest
144
+ identified_by :transfer_request_id
145
+ has_one :from_warehouse, :class => "Warehouse", :mandatory => true # See Warehouse.all_transfer_request_as_from_warehouse
146
+ has_one :product, :mandatory => true # See Product.all_transfer_request
147
+ has_one :quantity, :mandatory => true # See Quantity.all_transfer_request
148
+ has_one :to_warehouse, :class => "Warehouse", :mandatory => true # See Warehouse.all_transfer_request_as_to_warehouse
149
+ one_to_one :transfer_request_id, :class => TransferRequestID, :mandatory => true # See TransferRequestID.transfer_request
150
+ end
151
+
152
+ class Warehouse
153
+ identified_by :warehouse_id
154
+ one_to_one :warehouse_id, :class => WarehouseID, :mandatory => true # See WarehouseID.warehouse
155
+ end
156
+
157
+ class BackOrderAllocation
158
+ identified_by :purchase_order_item, :sales_order_item
159
+ has_one :purchase_order_item, :mandatory => true # See PurchaseOrderItem.all_back_order_allocation
160
+ has_one :sales_order_item, :mandatory => true # See SalesOrderItem.all_back_order_allocation
161
+ has_one :quantity, :mandatory => true # See Quantity.all_back_order_allocation
162
+ end
163
+
164
+ class Customer < Party
165
+ end
166
+
167
+ end
@@ -0,0 +1,45 @@
1
+ require 'activefacts/api'
2
+
3
+ module ::WindowInRoomInBldg
4
+
5
+ class BuildingNumber < SignedInteger
6
+ value_type :length => 32
7
+ one_to_one :building # See Building.building_number
8
+ end
9
+
10
+ class RoomNumber < SignedInteger
11
+ value_type :length => 32
12
+ end
13
+
14
+ class WallNumber < SignedInteger
15
+ value_type :length => 32
16
+ end
17
+
18
+ class WindowNumber < UnsignedInteger
19
+ value_type :length => 32
20
+ end
21
+
22
+ class Building
23
+ identified_by :building_number
24
+ one_to_one :building_number, :mandatory => true # See BuildingNumber.building
25
+ end
26
+
27
+ class Room
28
+ identified_by :building, :room_number
29
+ has_one :building, :mandatory => true # See Building.all_room
30
+ has_one :room_number, :mandatory => true # See RoomNumber.all_room
31
+ end
32
+
33
+ class Wall
34
+ identified_by :room, :wall_number
35
+ has_one :room, :mandatory => true # See Room.all_wall
36
+ has_one :wall_number, :mandatory => true # See WallNumber.all_wall
37
+ end
38
+
39
+ class Window
40
+ identified_by :wall, :window_number
41
+ has_one :wall, :mandatory => true # See Wall.all_window
42
+ has_one :window_number, :mandatory => true # See WindowNumber.all_window
43
+ end
44
+
45
+ end
@@ -0,0 +1,40 @@
1
+ CREATE TABLE Company (
2
+ -- maybe Company has head office at Address and Address is in City,
3
+ AddressCity varchar(64) NULL,
4
+ -- maybe Company has head office at Address and maybe Address is in Postcode,
5
+ AddressPostcode varchar NULL CHECK((AddressPostcode >= 1000 AND AddressPostcode <= 9999)),
6
+ -- maybe Company has head office at Address and Address is at Street and Street includes first-Street Line,
7
+ AddressStreetFirstStreetLine varchar(64) NULL,
8
+ -- maybe Company has head office at Address and maybe Address is at street-Number,
9
+ AddressStreetNumber varchar(12) NULL,
10
+ -- maybe Company has head office at Address and Address is at Street and maybe Street includes second-Street Line,
11
+ AddressStreetSecondStreetLine varchar(64) NULL,
12
+ -- maybe Company has head office at Address and Address is at Street and maybe Street includes third-Street Line,
13
+ AddressStreetThirdStreetLine varchar(64) NULL,
14
+ -- Company has Company Name,
15
+ CompanyName varchar NOT NULL,
16
+ PRIMARY KEY(CompanyName)
17
+ )
18
+ GO
19
+
20
+ CREATE TABLE Person (
21
+ -- maybe Person lives at Address and Address is in City,
22
+ AddressCity varchar(64) NULL,
23
+ -- maybe Person lives at Address and maybe Address is in Postcode,
24
+ AddressPostcode varchar NULL CHECK((AddressPostcode >= 1000 AND AddressPostcode <= 9999)),
25
+ -- maybe Person lives at Address and Address is at Street and Street includes first-Street Line,
26
+ AddressStreetFirstStreetLine varchar(64) NULL,
27
+ -- maybe Person lives at Address and maybe Address is at street-Number,
28
+ AddressStreetNumber varchar(12) NULL,
29
+ -- maybe Person lives at Address and Address is at Street and maybe Street includes second-Street Line,
30
+ AddressStreetSecondStreetLine varchar(64) NULL,
31
+ -- maybe Person lives at Address and Address is at Street and maybe Street includes third-Street Line,
32
+ AddressStreetThirdStreetLine varchar(64) NULL,
33
+ -- Person is of Family and Family has Family Name,
34
+ FamilyName varchar(20) NOT NULL,
35
+ -- Person has Given Names,
36
+ GivenNames varchar(20) NOT NULL,
37
+ PRIMARY KEY(FamilyName, GivenNames)
38
+ )
39
+ GO
40
+
@@ -0,0 +1,36 @@
1
+ CREATE TABLE AstronomicalObject (
2
+ -- AstronomicalObject has AstronomicalObject Code,
3
+ AstronomicalObjectCode varchar(12) NOT NULL,
4
+ -- AstronomicalObject is involved in Orbit,
5
+ IsInOrbit bit NULL,
6
+ -- maybe AstronomicalObject has Mass,
7
+ Mass Real(32) NULL,
8
+ -- maybe AstronomicalObject is a Moon and Moon has Moon Name,
9
+ MoonName varchar(256) NULL,
10
+ -- AstronomicalObject is involved in Orbit and Orbit is around AstronomicalObject and AstronomicalObject has AstronomicalObject Code,
11
+ OrbitCenterAstronomicalObjectCode varchar(12) NULL,
12
+ -- AstronomicalObject is involved in Orbit and maybe Orbit has a synodic period of Nr Days,
13
+ OrbitNrDays Real(32) NULL,
14
+ -- maybe AstronomicalObject is a Planet and Planet has Planet Name,
15
+ PlanetName varchar(256) NULL,
16
+ PRIMARY KEY(AstronomicalObjectCode),
17
+ FOREIGN KEY (OrbitCenterAstronomicalObjectCode) REFERENCES AstronomicalObject (AstronomicalObjectCode)
18
+ )
19
+ GO
20
+
21
+ CREATE VIEW dbo.MoonInAstronomicalObject_Name (MoonName) WITH SCHEMABINDING AS
22
+ SELECT MoonName FROM dbo.AstronomicalObject
23
+ WHERE MoonName IS NOT NULL
24
+ GO
25
+
26
+ CREATE UNIQUE CLUSTERED INDEX PK_MoonInAstronomicalObject ON dbo.MoonInAstronomicalObject_Name(MoonName)
27
+ GO
28
+
29
+ CREATE VIEW dbo.PlanetInAstronomicalObject_Name (PlanetName) WITH SCHEMABINDING AS
30
+ SELECT PlanetName FROM dbo.AstronomicalObject
31
+ WHERE PlanetName IS NOT NULL
32
+ GO
33
+
34
+ CREATE UNIQUE CLUSTERED INDEX PK_PlanetInAstronomicalObject ON dbo.PlanetInAstronomicalObject_Name(PlanetName)
35
+ GO
36
+
@@ -0,0 +1,78 @@
1
+ CREATE TABLE Author (
2
+ -- Author has Author Id,
3
+ AuthorId int IDENTITY NOT NULL,
4
+ -- Author is called Name,
5
+ AuthorName varchar(64) NOT NULL,
6
+ PRIMARY KEY(AuthorId),
7
+ UNIQUE(AuthorName)
8
+ )
9
+ GO
10
+
11
+ CREATE TABLE Comment (
12
+ -- Comment was written by Author and Author has Author Id,
13
+ AuthorId int NOT NULL,
14
+ -- Comment has Comment Id,
15
+ CommentId int IDENTITY NOT NULL,
16
+ -- Comment consists of text-Content and maybe Content is of Style,
17
+ ContentStyle varchar(20) NULL,
18
+ -- Comment consists of text-Content and Content has Text,
19
+ ContentText text NOT NULL,
20
+ -- Comment is on Paragraph and Paragraph involves Ordinal,
21
+ ParagraphOrdinal int NOT NULL,
22
+ -- Comment is on Paragraph and Paragraph involves Post and Post has Post Id,
23
+ ParagraphPostId int NOT NULL,
24
+ PRIMARY KEY(CommentId),
25
+ FOREIGN KEY (AuthorId) REFERENCES Author (AuthorId)
26
+ )
27
+ GO
28
+
29
+ CREATE TABLE Paragraph (
30
+ -- Paragraph contains Content and maybe Content is of Style,
31
+ ContentStyle varchar(20) NULL,
32
+ -- Paragraph contains Content and Content has Text,
33
+ ContentText text NOT NULL,
34
+ -- Paragraph involves Ordinal,
35
+ Ordinal int NOT NULL,
36
+ -- Paragraph involves Post and Post has Post Id,
37
+ PostId int NOT NULL,
38
+ PRIMARY KEY(PostId, Ordinal)
39
+ )
40
+ GO
41
+
42
+ CREATE TABLE Post (
43
+ -- Post was written by Author and Author has Author Id,
44
+ AuthorId int NOT NULL,
45
+ -- Post has Post Id,
46
+ PostId int IDENTITY NOT NULL,
47
+ -- Post belongs to Topic and Topic has Topic Id,
48
+ TopicId int NOT NULL,
49
+ PRIMARY KEY(PostId),
50
+ FOREIGN KEY (AuthorId) REFERENCES Author (AuthorId)
51
+ )
52
+ GO
53
+
54
+ CREATE TABLE Topic (
55
+ -- maybe Topic belongs to parent-Topic and Topic has Topic Id,
56
+ ParentTopicId int NULL,
57
+ -- Topic has Topic Id,
58
+ TopicId int IDENTITY NOT NULL,
59
+ -- Topic is called topic-Name,
60
+ TopicName varchar(64) NOT NULL,
61
+ PRIMARY KEY(TopicId),
62
+ UNIQUE(TopicName),
63
+ FOREIGN KEY (ParentTopicId) REFERENCES Topic (TopicId)
64
+ )
65
+ GO
66
+
67
+ ALTER TABLE Comment
68
+ ADD FOREIGN KEY (ParagraphPostId, ParagraphOrdinal) REFERENCES Paragraph (PostId, Ordinal)
69
+ GO
70
+
71
+ ALTER TABLE Paragraph
72
+ ADD FOREIGN KEY (PostId) REFERENCES Post (PostId)
73
+ GO
74
+
75
+ ALTER TABLE Post
76
+ ADD FOREIGN KEY (TopicId) REFERENCES Topic (TopicId)
77
+ GO
78
+
@@ -0,0 +1,95 @@
1
+ CREATE TABLE Booking (
2
+ -- Booking is confirmed Boolean,
3
+ IsConfirmed bit NULL,
4
+ -- Booking involves Number,
5
+ Number smallint NOT NULL CHECK(Number >= 1),
6
+ -- Booking involves Person and Person has Person ID,
7
+ PersonID int NOT NULL,
8
+ -- Booking involves Session and Session involves Cinema and Cinema has Cinema ID,
9
+ SessionCinemaID int NOT NULL,
10
+ -- Booking involves Session and Session involves DateTime and DateTime has DateTime Value,
11
+ SessionDateTimeValue datetime NOT NULL,
12
+ PRIMARY KEY(PersonID, SessionCinemaID, SessionDateTimeValue)
13
+ )
14
+ GO
15
+
16
+ CREATE TABLE Cinema (
17
+ -- Cinema has Cinema ID,
18
+ CinemaID int IDENTITY NOT NULL,
19
+ PRIMARY KEY(CinemaID)
20
+ )
21
+ GO
22
+
23
+ CREATE TABLE Film (
24
+ -- Film has Film ID,
25
+ FilmID int IDENTITY NOT NULL,
26
+ -- maybe Film has Name,
27
+ Name varchar NULL,
28
+ PRIMARY KEY(FilmID)
29
+ )
30
+ GO
31
+
32
+ CREATE TABLE Person (
33
+ -- Person has login-Name,
34
+ LoginName varchar NOT NULL,
35
+ -- Person has Person ID,
36
+ PersonID int IDENTITY NOT NULL,
37
+ PRIMARY KEY(PersonID),
38
+ UNIQUE(LoginName)
39
+ )
40
+ GO
41
+
42
+ CREATE TABLE Seat (
43
+ -- Seat is in Row and Row is in Cinema and Cinema has Cinema ID,
44
+ RowCinemaID int NOT NULL,
45
+ -- Seat is in Row and Row has Row Nr,
46
+ RowNr char(2) NOT NULL,
47
+ -- Seat has Seat Number,
48
+ SeatNumber smallint NOT NULL,
49
+ -- maybe Seat is in Section and Section has Section Name,
50
+ SectionName varchar NULL,
51
+ PRIMARY KEY(RowCinemaID, RowNr, SeatNumber),
52
+ FOREIGN KEY (RowCinemaID) REFERENCES Cinema (CinemaID)
53
+ )
54
+ GO
55
+
56
+ CREATE TABLE SeatAllocation (
57
+ -- Seat Allocation involves Seat and Seat has Seat Number,
58
+ AllocatedSeatNumber smallint NOT NULL,
59
+ -- Seat Allocation involves Seat and Seat is in Row and Row is in Cinema and Cinema has Cinema ID,
60
+ AllocatedSeatRowCinemaID int NOT NULL,
61
+ -- Seat Allocation involves Seat and Seat is in Row and Row has Row Nr,
62
+ AllocatedSeatRowNr char(2) NOT NULL,
63
+ -- Seat Allocation involves Booking and Booking involves Person and Person has Person ID,
64
+ BookingPersonID int NOT NULL,
65
+ -- Seat Allocation involves Booking and Booking involves Session and Session involves Cinema and Cinema has Cinema ID,
66
+ BookingSessionCinemaID int NOT NULL,
67
+ -- Seat Allocation involves Booking and Booking involves Session and Session involves DateTime and DateTime has DateTime Value,
68
+ BookingSessionDateTimeValue datetime NOT NULL,
69
+ PRIMARY KEY(BookingPersonID, BookingSessionCinemaID, BookingSessionDateTimeValue, AllocatedSeatRowCinemaID, AllocatedSeatRowNr, AllocatedSeatNumber),
70
+ FOREIGN KEY (BookingPersonID, BookingSessionCinemaID, BookingSessionDateTimeValue) REFERENCES Booking (PersonID, SessionCinemaID, SessionDateTimeValue),
71
+ FOREIGN KEY (AllocatedSeatRowCinemaID, AllocatedSeatRowNr, AllocatedSeatNumber) REFERENCES Seat (RowCinemaID, RowNr, SeatNumber)
72
+ )
73
+ GO
74
+
75
+ CREATE TABLE Session (
76
+ -- Session involves Cinema and Cinema has Cinema ID,
77
+ CinemaID int NOT NULL,
78
+ -- Session involves DateTime and DateTime has DateTime Value,
79
+ DateTimeValue datetime NOT NULL,
80
+ -- Session involves Film and Film has Film ID,
81
+ FilmID int NOT NULL,
82
+ PRIMARY KEY(CinemaID, DateTimeValue),
83
+ FOREIGN KEY (CinemaID) REFERENCES Cinema (CinemaID),
84
+ FOREIGN KEY (FilmID) REFERENCES Film (FilmID)
85
+ )
86
+ GO
87
+
88
+ ALTER TABLE Booking
89
+ ADD FOREIGN KEY (PersonID) REFERENCES Person (PersonID)
90
+ GO
91
+
92
+ ALTER TABLE Booking
93
+ ADD FOREIGN KEY (SessionCinemaID, SessionDateTimeValue) REFERENCES Session (CinemaID, DateTimeValue)
94
+ GO
95
+