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,484 @@
1
+ CREATE TABLE Asset (
2
+ -- Asset has Asset ID,
3
+ AssetID int IDENTITY NOT NULL,
4
+ -- maybe Asset is a Vehicle and maybe Vehicle is of Colour,
5
+ VehicleColour varchar NULL,
6
+ -- maybe Asset is a Vehicle and maybe Vehicle was sold by Dealer and Dealer is a kind of Party and Party has Party ID,
7
+ VehicleDealerID int NULL,
8
+ -- maybe Asset is a Vehicle and maybe Vehicle has Engine Number,
9
+ VehicleEngineNumber varchar NULL,
10
+ -- maybe Asset is a Vehicle and maybe Vehicle is subject to finance with Finance Institution and Finance Institution is a kind of Company and Company is a kind of Party and Party has Party ID,
11
+ VehicleFinanceInstitutionID int NULL,
12
+ -- maybe Asset is a Vehicle and Vehicle has commercial registration Boolean,
13
+ VehicleHasCommercialRegistration bit NULL,
14
+ -- maybe Asset is a Vehicle and Vehicle is of model-Year and Year has Year Nr,
15
+ VehicleModelYearNr int NULL,
16
+ -- maybe Asset is a Vehicle and Vehicle has Registration and Registration has Registration Nr,
17
+ VehicleRegistrationNr char(8) NULL,
18
+ -- maybe Asset is a Vehicle and Vehicle is of Vehicle Type and maybe Vehicle Type has Badge,
19
+ VehicleTypeBadge varchar NULL,
20
+ -- maybe Asset is a Vehicle and Vehicle is of Vehicle Type and Vehicle Type is of Make,
21
+ VehicleTypeMake varchar NULL,
22
+ -- maybe Asset is a Vehicle and Vehicle is of Vehicle Type and Vehicle Type is of Model,
23
+ VehicleTypeModel varchar NULL,
24
+ -- maybe Asset is a Vehicle and Vehicle has VIN,
25
+ VehicleVIN int NULL,
26
+ PRIMARY KEY(AssetID)
27
+ )
28
+ GO
29
+
30
+ CREATE VIEW dbo.VehicleInAsset_VIN (VehicleVIN) WITH SCHEMABINDING AS
31
+ SELECT VehicleVIN FROM dbo.Asset
32
+ WHERE VehicleVIN IS NOT NULL
33
+ GO
34
+
35
+ CREATE UNIQUE CLUSTERED INDEX VehiclePK ON dbo.VehicleInAsset_VIN(VehicleVIN)
36
+ GO
37
+
38
+ CREATE TABLE Claim (
39
+ -- Claim has Claim ID,
40
+ ClaimID int IDENTITY NOT NULL,
41
+ -- maybe Claim concerns Incident and Incident relates to loss at Address and Address is in City,
42
+ IncidentAddressCity varchar NULL,
43
+ -- maybe Claim concerns Incident and Incident relates to loss at Address and maybe Address is in Postcode,
44
+ IncidentAddressPostcode varchar NULL,
45
+ -- maybe Claim concerns Incident and Incident relates to loss at Address and maybe Address is in State and State has State Code,
46
+ IncidentAddressStateCode tinyint NULL CHECK((IncidentAddressStateCode >= 0 AND IncidentAddressStateCode <= 9)),
47
+ -- maybe Claim concerns Incident and Incident relates to loss at Address and Address is at Street,
48
+ IncidentAddressStreet varchar(256) NULL,
49
+ -- maybe Claim concerns Incident and Incident relates to loss on Date Time,
50
+ IncidentDateTime datetime NULL,
51
+ -- maybe Claim concerns Incident and maybe Incident is covered by Police Report and maybe Police Report was to officer-Name,
52
+ IncidentOfficerName varchar(256) NULL,
53
+ -- maybe Claim concerns Incident and maybe Incident is covered by Police Report and maybe Police Report has police-Report Nr,
54
+ IncidentPoliceReportNr int NULL,
55
+ -- maybe Claim concerns Incident and maybe Incident is covered by Police Report and maybe Police Report was on report-Date Time,
56
+ IncidentReportDateTime datetime NULL,
57
+ -- maybe Claim concerns Incident and maybe Incident is covered by Police Report and maybe Police Report was by reporter-Name,
58
+ IncidentReporterName varchar(256) NULL,
59
+ -- maybe Claim concerns Incident and maybe Incident is covered by Police Report and maybe Police Report was at station-Name,
60
+ IncidentStationName varchar(256) NULL,
61
+ -- Claim is involved in Lodgement and maybe Lodgement was made at Date Time,
62
+ LodgementDateTime datetime NULL,
63
+ -- Claim is involved in Lodgement and Lodgement involves Person and Person is a kind of Party and Party has Party ID,
64
+ LodgementPersonID int NOT NULL,
65
+ -- Claim has Claim Sequence,
66
+ PSequence int NOT NULL CHECK((PSequence >= 1 AND PSequence <= 999)),
67
+ -- Claim is on Policy and Policy is for product having Product and Product has Product Code,
68
+ PolicyPProductCode tinyint NOT NULL,
69
+ -- Claim is on Policy and Policy has Policy Serial,
70
+ PolicyPSerial int NOT NULL,
71
+ -- Claim is on Policy and Policy issued in state having State and State has State Code,
72
+ PolicyPStateCode tinyint NOT NULL,
73
+ -- Claim is on Policy and Policy was issued in Year and Year has Year Nr,
74
+ PolicyPYearNr int NOT NULL,
75
+ PRIMARY KEY(ClaimID),
76
+ UNIQUE(PolicyPYearNr, PolicyPProductCode, PolicyPStateCode, PolicyPSerial, PSequence)
77
+ )
78
+ GO
79
+
80
+ CREATE TABLE ContractorAppointment (
81
+ -- Contractor Appointment involves Claim and Claim has Claim ID,
82
+ ClaimID int NOT NULL,
83
+ -- Contractor Appointment involves Contractor and Contractor is a kind of Company and Company is a kind of Party and Party has Party ID,
84
+ ContractorID int NOT NULL,
85
+ PRIMARY KEY(ClaimID, ContractorID),
86
+ FOREIGN KEY (ClaimID) REFERENCES Claim (ClaimID)
87
+ )
88
+ GO
89
+
90
+ CREATE TABLE Cover (
91
+ -- Cover involves Asset and Asset has Asset ID,
92
+ AssetID int NOT NULL,
93
+ -- Cover involves Cover Type and Cover Type has Cover Type Code,
94
+ CoverTypeCode char NOT NULL,
95
+ -- Cover involves Policy and Policy is for product having Product and Product has Product Code,
96
+ PolicyPProductCode tinyint NOT NULL,
97
+ -- Cover involves Policy and Policy has Policy Serial,
98
+ PolicyPSerial int NOT NULL,
99
+ -- Cover involves Policy and Policy issued in state having State and State has State Code,
100
+ PolicyPStateCode tinyint NOT NULL,
101
+ -- Cover involves Policy and Policy was issued in Year and Year has Year Nr,
102
+ PolicyPYearNr int NOT NULL,
103
+ PRIMARY KEY(PolicyPYearNr, PolicyPProductCode, PolicyPStateCode, PolicyPSerial, CoverTypeCode, AssetID),
104
+ FOREIGN KEY (AssetID) REFERENCES Asset (AssetID)
105
+ )
106
+ GO
107
+
108
+ CREATE TABLE CoverType (
109
+ -- Cover Type has Cover Type Code,
110
+ CoverTypeCode char NOT NULL,
111
+ -- Cover Type has Cover Type Name,
112
+ CoverTypeName varchar NOT NULL,
113
+ PRIMARY KEY(CoverTypeCode),
114
+ UNIQUE(CoverTypeName)
115
+ )
116
+ GO
117
+
118
+ CREATE TABLE CoverWording (
119
+ -- Cover Wording involves Cover Type and Cover Type has Cover Type Code,
120
+ CoverTypeCode char NOT NULL,
121
+ -- Cover Wording involves Policy Wording and Policy Wording has Policy Wording Text,
122
+ PolicyWordingText varchar NOT NULL,
123
+ -- Cover Wording involves Date,
124
+ StartDate datetime NOT NULL,
125
+ PRIMARY KEY(CoverTypeCode, PolicyWordingText, StartDate),
126
+ FOREIGN KEY (CoverTypeCode) REFERENCES CoverType (CoverTypeCode)
127
+ )
128
+ GO
129
+
130
+ CREATE TABLE LossType (
131
+ -- Loss Type involves driving Boolean,
132
+ InvolvesDriving bit NULL,
133
+ -- Loss Type is single vehicle incident Boolean,
134
+ IsSingleVehicleIncident bit NULL,
135
+ -- maybe Loss Type implies Liability and Liability has Liability Code,
136
+ LiabilityCode char(1) NULL CHECK(LiabilityCode = 'D' OR LiabilityCode = 'L' OR LiabilityCode = 'R' OR LiabilityCode = 'U'),
137
+ -- Loss Type has Loss Type Code,
138
+ LossTypeCode char NOT NULL,
139
+ PRIMARY KEY(LossTypeCode)
140
+ )
141
+ GO
142
+
143
+ CREATE TABLE LostItem (
144
+ -- Lost Item has Description,
145
+ Description varchar(1024) NOT NULL,
146
+ -- Lost Item was lost in Incident and Incident is of Claim and Claim has Claim ID,
147
+ IncidentClaimID int NOT NULL,
148
+ -- Lost Item has Lost Item Nr,
149
+ LostItemNr int NOT NULL,
150
+ -- maybe Lost Item was purchased on purchase-Date,
151
+ PurchaseDate datetime NULL,
152
+ -- maybe Lost Item was purchased at purchase-Place,
153
+ PurchasePlace varchar NULL,
154
+ -- maybe Lost Item was purchased for purchase-Price,
155
+ PurchasePrice decimal(18, 2) NULL,
156
+ PRIMARY KEY(IncidentClaimID, LostItemNr),
157
+ FOREIGN KEY (IncidentClaimID) REFERENCES Claim (ClaimID)
158
+ )
159
+ GO
160
+
161
+ CREATE TABLE Party (
162
+ -- maybe Party is a Company and Company has contact-Person and Person is a kind of Party and Party has Party ID,
163
+ CompanyContactPersonID int NULL,
164
+ -- Party is a company Boolean,
165
+ IsACompany bit NULL,
166
+ -- Party has Party ID,
167
+ PartyID int IDENTITY NOT NULL,
168
+ -- maybe Party is a Person and maybe Person lives at Address and Address is in City,
169
+ PersonAddressCity varchar NULL,
170
+ -- maybe Party is a Person and maybe Person lives at Address and maybe Address is in Postcode,
171
+ PersonAddressPostcode varchar NULL,
172
+ -- maybe Party is a Person and maybe Person lives at Address and maybe Address is in State and State has State Code,
173
+ PersonAddressStateCode tinyint NULL CHECK((PersonAddressStateCode >= 0 AND PersonAddressStateCode <= 9)),
174
+ -- maybe Party is a Person and maybe Person lives at Address and Address is at Street,
175
+ PersonAddressStreet varchar(256) NULL,
176
+ -- maybe Party is a Person and maybe Person has birth-Date,
177
+ PersonBirthDate datetime NULL,
178
+ -- maybe Party is a Person and Person has Contact Methods and maybe Contact Methods includes business-Phone and Phone has Phone Nr,
179
+ PersonBusinessPhoneNr varchar NULL,
180
+ -- maybe Party is a Person and Person has Contact Methods and maybe Contact Methods prefers contact-Time,
181
+ PersonContactTime datetime NULL,
182
+ -- maybe Party is a Person and Person has Contact Methods and maybe Contact Methods includes Email,
183
+ PersonEmail varchar NULL,
184
+ -- maybe Party is a Person and Person has family-Name,
185
+ PersonFamilyName varchar(256) NULL,
186
+ -- maybe Party is a Person and Person has given-Name,
187
+ PersonGivenName varchar(256) NULL,
188
+ -- maybe Party is a Person and Person has Contact Methods and maybe Contact Methods includes home-Phone and Phone has Phone Nr,
189
+ PersonHomePhoneNr varchar NULL,
190
+ -- maybe Party is a Person and maybe Person holds License and License is international Boolean,
191
+ PersonIsInternational bit NULL,
192
+ -- maybe Party is a Person and maybe Person holds License and License has License Number,
193
+ PersonLicenseNumber varchar NULL,
194
+ -- maybe Party is a Person and maybe Person holds License and License is of License Type,
195
+ PersonLicenseType varchar NULL,
196
+ -- maybe Party is a Person and Person has Contact Methods and maybe Contact Methods includes mobile-Phone and Phone has Phone Nr,
197
+ PersonMobilePhoneNr varchar NULL,
198
+ -- maybe Party is a Person and maybe Person has Occupation,
199
+ PersonOccupation varchar NULL,
200
+ -- maybe Party is a Person and Person has Contact Methods and maybe Contact Methods has preferred-Contact Method,
201
+ PersonPreferredContactMethod char(1) NULL CHECK(PersonPreferredContactMethod = 'B' OR PersonPreferredContactMethod = 'H' OR PersonPreferredContactMethod = 'M'),
202
+ -- maybe Party is a Person and Person has Title,
203
+ PersonTitle varchar NULL,
204
+ -- maybe Party is a Person and maybe Person holds License and maybe License was granted in Year and Year has Year Nr,
205
+ PersonYearNr int NULL,
206
+ -- maybe Party has postal-Address and Address is in City,
207
+ PostalAddressCity varchar NULL,
208
+ -- maybe Party has postal-Address and maybe Address is in Postcode,
209
+ PostalAddressPostcode varchar NULL,
210
+ -- maybe Party has postal-Address and maybe Address is in State and State has State Code,
211
+ PostalAddressStateCode tinyint NULL CHECK((PostalAddressStateCode >= 0 AND PostalAddressStateCode <= 9)),
212
+ -- maybe Party has postal-Address and Address is at Street,
213
+ PostalAddressStreet varchar(256) NULL,
214
+ PRIMARY KEY(PartyID),
215
+ FOREIGN KEY (CompanyContactPersonID) REFERENCES Party (PartyID)
216
+ )
217
+ GO
218
+
219
+ CREATE VIEW dbo.LicenseInParty_PersonLicenseNumber (PersonLicenseNumber) WITH SCHEMABINDING AS
220
+ SELECT PersonLicenseNumber FROM dbo.Party
221
+ WHERE PersonLicenseNumber IS NOT NULL
222
+ GO
223
+
224
+ CREATE UNIQUE CLUSTERED INDEX IX_LicenseInPartyByPersonLicenseNumber ON dbo.LicenseInParty_PersonLicenseNumber(PersonLicenseNumber)
225
+ GO
226
+
227
+ CREATE TABLE Policy (
228
+ -- Policy has Application and Application has Application Nr,
229
+ ApplicationNr int NOT NULL,
230
+ -- maybe Policy was sold by Authorised Rep and Authorised Rep is a kind of Party and Party has Party ID,
231
+ AuthorisedRepID int NULL,
232
+ -- maybe Policy has ITC Claimed,
233
+ ITCClaimed decimal(18, 2) NULL CHECK((ITCClaimed >= 0.0 AND ITCClaimed <= 100.0)),
234
+ -- Policy belongs to Insured and Insured is a kind of Party and Party has Party ID,
235
+ InsuredID int NOT NULL,
236
+ -- Policy is for product having Product and Product has Product Code,
237
+ PProductCode tinyint NOT NULL,
238
+ -- Policy has Policy Serial,
239
+ PSerial int NOT NULL CHECK((PSerial >= 1 AND PSerial <= 99999)),
240
+ -- Policy issued in state having State and State has State Code,
241
+ PStateCode tinyint NOT NULL,
242
+ -- Policy was issued in Year and Year has Year Nr,
243
+ PYearNr int NOT NULL,
244
+ PRIMARY KEY(PYearNr, PProductCode, PStateCode, PSerial),
245
+ FOREIGN KEY (AuthorisedRepID) REFERENCES Party (PartyID),
246
+ FOREIGN KEY (InsuredID) REFERENCES Party (PartyID)
247
+ )
248
+ GO
249
+
250
+ CREATE TABLE Product (
251
+ -- maybe Product has Alias,
252
+ Alias char(3) NULL,
253
+ -- maybe Product has Description,
254
+ Description varchar(1024) NULL,
255
+ -- Product has Product Code,
256
+ ProductCode tinyint NOT NULL CHECK((ProductCode >= 1 AND ProductCode <= 99)),
257
+ PRIMARY KEY(ProductCode)
258
+ )
259
+ GO
260
+
261
+ CREATE VIEW dbo.Product_Alias (Alias) WITH SCHEMABINDING AS
262
+ SELECT Alias FROM dbo.Product
263
+ WHERE Alias IS NOT NULL
264
+ GO
265
+
266
+ CREATE UNIQUE CLUSTERED INDEX IX_ProductByAlias ON dbo.Product_Alias(Alias)
267
+ GO
268
+
269
+ CREATE VIEW dbo.Product_Description (Description) WITH SCHEMABINDING AS
270
+ SELECT Description FROM dbo.Product
271
+ WHERE Description IS NOT NULL
272
+ GO
273
+
274
+ CREATE UNIQUE CLUSTERED INDEX IX_ProductByDescription ON dbo.Product_Description(Description)
275
+ GO
276
+
277
+ CREATE TABLE PropertyDamage (
278
+ -- Property Damage is at Address and Address is in City,
279
+ AddressCity varchar NOT NULL,
280
+ -- Property Damage is at Address and maybe Address is in Postcode,
281
+ AddressPostcode varchar NULL,
282
+ -- Property Damage is at Address and maybe Address is in State and State has State Code,
283
+ AddressStateCode tinyint NULL CHECK((AddressStateCode >= 0 AND AddressStateCode <= 9)),
284
+ -- Property Damage is at Address and Address is at Street,
285
+ AddressStreet varchar(256) NOT NULL,
286
+ -- maybe Property Damage was damaged in Incident and Incident is of Claim and Claim has Claim ID,
287
+ IncidentClaimID int NULL,
288
+ -- maybe Property Damage belongs to owner-Name,
289
+ OwnerName varchar(256) NULL,
290
+ -- maybe Property Damage owner has contact Phone and Phone has Phone Nr,
291
+ PhoneNr varchar NULL,
292
+ UNIQUE(IncidentClaimID, AddressStreet, AddressCity, AddressPostcode, AddressStateCode),
293
+ FOREIGN KEY (IncidentClaimID) REFERENCES Claim (ClaimID)
294
+ )
295
+ GO
296
+
297
+ CREATE TABLE State (
298
+ -- State has State Code,
299
+ StateCode tinyint NOT NULL CHECK((StateCode >= 0 AND StateCode <= 9)),
300
+ -- maybe State has State Name,
301
+ StateName varchar(256) NULL,
302
+ PRIMARY KEY(StateCode)
303
+ )
304
+ GO
305
+
306
+ CREATE VIEW dbo.State_Name (StateName) WITH SCHEMABINDING AS
307
+ SELECT StateName FROM dbo.State
308
+ WHERE StateName IS NOT NULL
309
+ GO
310
+
311
+ CREATE UNIQUE CLUSTERED INDEX IX_StateByStateName ON dbo.State_Name(StateName)
312
+ GO
313
+
314
+ CREATE TABLE ThirdParty (
315
+ -- maybe Third Party is insured by Insurer and Insurer is a kind of Company and Company is a kind of Party and Party has Party ID,
316
+ InsurerID int NULL,
317
+ -- maybe Third Party vehicle is of model-Year and Year has Year Nr,
318
+ ModelYearNr int NULL,
319
+ -- Third Party involves Person and Person is a kind of Party and Party has Party ID,
320
+ PersonID int NOT NULL,
321
+ -- Third Party involves Vehicle Incident and Vehicle Incident is a kind of Incident and Incident is of Claim and Claim has Claim ID,
322
+ VehicleIncidentClaimID int NOT NULL,
323
+ -- maybe Third Party drove vehicle-Registration and Registration has Registration Nr,
324
+ VehicleRegistrationNr char(8) NULL,
325
+ -- maybe Third Party vehicle is of Vehicle Type and maybe Vehicle Type has Badge,
326
+ VehicleTypeBadge varchar NULL,
327
+ -- maybe Third Party vehicle is of Vehicle Type and Vehicle Type is of Make,
328
+ VehicleTypeMake varchar NULL,
329
+ -- maybe Third Party vehicle is of Vehicle Type and Vehicle Type is of Model,
330
+ VehicleTypeModel varchar NULL,
331
+ PRIMARY KEY(PersonID, VehicleIncidentClaimID),
332
+ FOREIGN KEY (InsurerID) REFERENCES Party (PartyID),
333
+ FOREIGN KEY (PersonID) REFERENCES Party (PartyID)
334
+ )
335
+ GO
336
+
337
+ CREATE TABLE UnderwritingDemerit (
338
+ -- maybe Underwriting Demerit occurred occurrence-Count times,
339
+ OccurrenceCount int NULL,
340
+ -- Underwriting Demerit has Underwriting Question and Underwriting Question has Underwriting Question ID,
341
+ UnderwritingQuestionID int NOT NULL,
342
+ -- Underwriting Demerit preceded Vehicle Incident and Vehicle Incident is a kind of Incident and Incident is of Claim and Claim has Claim ID,
343
+ VehicleIncidentClaimID int NOT NULL,
344
+ PRIMARY KEY(VehicleIncidentClaimID, UnderwritingQuestionID)
345
+ )
346
+ GO
347
+
348
+ CREATE TABLE UnderwritingQuestion (
349
+ -- Underwriting Question has Text,
350
+ Text varchar NOT NULL,
351
+ -- Underwriting Question has Underwriting Question ID,
352
+ UnderwritingQuestionID int IDENTITY NOT NULL,
353
+ PRIMARY KEY(UnderwritingQuestionID),
354
+ UNIQUE(Text)
355
+ )
356
+ GO
357
+
358
+ CREATE TABLE VehicleIncident (
359
+ -- maybe Vehicle Incident has Description,
360
+ Description varchar(1024) NULL,
361
+ -- Vehicle Incident is involved in Driving and maybe Driving is involved in Hospitalization and maybe Hospitalization resulted in blood-Test Result,
362
+ DrivingBloodTestResult varchar NULL,
363
+ -- Vehicle Incident is involved in Driving and maybe Driving resulted in breath-Test Result,
364
+ DrivingBreathTestResult varchar NULL,
365
+ -- Vehicle Incident is involved in Driving and maybe Driving is involved in Driving Charge and Driving Charge involves Charge,
366
+ DrivingCharge varchar NULL,
367
+ -- Vehicle Incident is involved in Driving and maybe Driving is involved in Hospitalization and Hospitalization involves Hospital and Hospital has Hospital Name,
368
+ DrivingHospitalName varchar NULL,
369
+ -- Vehicle Incident is involved in Driving and maybe Driving followed Intoxication,
370
+ DrivingIntoxication varchar NULL,
371
+ -- Vehicle Incident is involved in Driving and maybe Driving is involved in Driving Charge and Driving Charge is a warning Boolean,
372
+ DrivingIsAWarning bit NULL,
373
+ -- Vehicle Incident is involved in Driving and maybe Driving was without owners consent for nonconsent-Reason,
374
+ DrivingNonconsentReason varchar NULL,
375
+ -- Vehicle Incident is involved in Driving and Driving was by Person and Person is a kind of Party and Party has Party ID,
376
+ DrivingPersonID int NULL,
377
+ -- Vehicle Incident is involved in Driving and maybe Driving was unlicenced for unlicensed-Reason,
378
+ DrivingUnlicensedReason varchar NULL,
379
+ -- Vehicle Incident is a kind of Incident and Incident is of Claim and Claim has Claim ID,
380
+ IncidentClaimID int NOT NULL,
381
+ -- maybe Vehicle Incident resulted from Loss Type and Loss Type has Loss Type Code,
382
+ LossTypeCode char NULL,
383
+ -- Vehicle Incident is involved in Driving,
384
+ OccurredWhileBeingDriven bit NULL,
385
+ -- maybe Vehicle Incident involved previous_damage-Description,
386
+ PreviousDamageDescription varchar(1024) NULL,
387
+ -- maybe Vehicle Incident was caused by Reason,
388
+ Reason varchar NULL,
389
+ -- maybe Vehicle Incident resulted in vehicle being towed to towed-Location,
390
+ TowedLocation varchar NULL,
391
+ -- maybe Vehicle Incident occurred during weather-Description,
392
+ WeatherDescription varchar(1024) NULL,
393
+ PRIMARY KEY(IncidentClaimID),
394
+ FOREIGN KEY (IncidentClaimID) REFERENCES Claim (ClaimID),
395
+ FOREIGN KEY (LossTypeCode) REFERENCES LossType (LossTypeCode),
396
+ FOREIGN KEY (DrivingPersonID) REFERENCES Party (PartyID)
397
+ )
398
+ GO
399
+
400
+ CREATE TABLE Witness (
401
+ -- maybe Witness lives at Address and Address is in City,
402
+ AddressCity varchar NULL,
403
+ -- maybe Witness lives at Address and maybe Address is in Postcode,
404
+ AddressPostcode varchar NULL,
405
+ -- maybe Witness lives at Address and maybe Address is in State and State has State Code,
406
+ AddressStateCode tinyint NULL CHECK((AddressStateCode >= 0 AND AddressStateCode <= 9)),
407
+ -- maybe Witness lives at Address and Address is at Street,
408
+ AddressStreet varchar(256) NULL,
409
+ -- maybe Witness has contact-Phone and Phone has Phone Nr,
410
+ ContactPhoneNr varchar NULL,
411
+ -- Witness saw Incident and Incident is of Claim and Claim has Claim ID,
412
+ IncidentClaimID int NOT NULL,
413
+ -- Witness is called Name,
414
+ Name varchar(256) NOT NULL,
415
+ PRIMARY KEY(IncidentClaimID, Name),
416
+ FOREIGN KEY (IncidentClaimID) REFERENCES Claim (ClaimID),
417
+ FOREIGN KEY (AddressStateCode) REFERENCES State (StateCode)
418
+ )
419
+ GO
420
+
421
+ ALTER TABLE Asset
422
+ ADD FOREIGN KEY (VehicleDealerID) REFERENCES Party (PartyID)
423
+ GO
424
+
425
+ ALTER TABLE Asset
426
+ ADD FOREIGN KEY (VehicleFinanceInstitutionID) REFERENCES Party (PartyID)
427
+ GO
428
+
429
+ ALTER TABLE Claim
430
+ ADD FOREIGN KEY (LodgementPersonID) REFERENCES Party (PartyID)
431
+ GO
432
+
433
+ ALTER TABLE Claim
434
+ ADD FOREIGN KEY (PolicyPYearNr, PolicyPProductCode, PolicyPStateCode, PolicyPSerial) REFERENCES Policy (PYearNr, PProductCode, PStateCode, PSerial)
435
+ GO
436
+
437
+ ALTER TABLE Claim
438
+ ADD FOREIGN KEY (IncidentAddressStateCode) REFERENCES State (StateCode)
439
+ GO
440
+
441
+ ALTER TABLE ContractorAppointment
442
+ ADD FOREIGN KEY (ContractorID) REFERENCES Party (PartyID)
443
+ GO
444
+
445
+ ALTER TABLE Cover
446
+ ADD FOREIGN KEY (CoverTypeCode) REFERENCES CoverType (CoverTypeCode)
447
+ GO
448
+
449
+ ALTER TABLE Cover
450
+ ADD FOREIGN KEY (PolicyPYearNr, PolicyPProductCode, PolicyPStateCode, PolicyPSerial) REFERENCES Policy (PYearNr, PProductCode, PStateCode, PSerial)
451
+ GO
452
+
453
+ ALTER TABLE Party
454
+ ADD FOREIGN KEY (PersonAddressStateCode) REFERENCES State (StateCode)
455
+ GO
456
+
457
+ ALTER TABLE Party
458
+ ADD FOREIGN KEY (PostalAddressStateCode) REFERENCES State (StateCode)
459
+ GO
460
+
461
+ ALTER TABLE Policy
462
+ ADD FOREIGN KEY (PProductCode) REFERENCES Product (ProductCode)
463
+ GO
464
+
465
+ ALTER TABLE Policy
466
+ ADD FOREIGN KEY (PStateCode) REFERENCES State (StateCode)
467
+ GO
468
+
469
+ ALTER TABLE PropertyDamage
470
+ ADD FOREIGN KEY (AddressStateCode) REFERENCES State (StateCode)
471
+ GO
472
+
473
+ ALTER TABLE ThirdParty
474
+ ADD FOREIGN KEY (VehicleIncidentClaimID) REFERENCES VehicleIncident (IncidentClaimID)
475
+ GO
476
+
477
+ ALTER TABLE UnderwritingDemerit
478
+ ADD FOREIGN KEY (UnderwritingQuestionID) REFERENCES UnderwritingQuestion (UnderwritingQuestionID)
479
+ GO
480
+
481
+ ALTER TABLE UnderwritingDemerit
482
+ ADD FOREIGN KEY (VehicleIncidentClaimID) REFERENCES VehicleIncident (IncidentClaimID)
483
+ GO
484
+
@@ -0,0 +1,30 @@
1
+ CREATE TABLE Marriage (
2
+ -- Marriage is by husband-Person and Person has family-Name,
3
+ HusbandFamilyName varchar NOT NULL,
4
+ -- Marriage is by husband-Person and Person has given-Name,
5
+ HusbandGivenName varchar NOT NULL,
6
+ -- Marriage is of wife-Person and Person has family-Name,
7
+ WifeFamilyName varchar NOT NULL,
8
+ -- Marriage is of wife-Person and Person has given-Name,
9
+ WifeGivenName varchar NOT NULL,
10
+ PRIMARY KEY(HusbandGivenName, HusbandFamilyName, WifeGivenName, WifeFamilyName)
11
+ )
12
+ GO
13
+
14
+ CREATE TABLE Person (
15
+ -- Person has family-Name,
16
+ FamilyName varchar NOT NULL,
17
+ -- Person has given-Name,
18
+ GivenName varchar NOT NULL,
19
+ PRIMARY KEY(GivenName, FamilyName)
20
+ )
21
+ GO
22
+
23
+ ALTER TABLE Marriage
24
+ ADD FOREIGN KEY (HusbandGivenName, HusbandFamilyName) REFERENCES Person (GivenName, FamilyName)
25
+ GO
26
+
27
+ ALTER TABLE Marriage
28
+ ADD FOREIGN KEY (WifeGivenName, WifeFamilyName) REFERENCES Person (GivenName, FamilyName)
29
+ GO
30
+