activefacts-examples 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.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +22 -0
- data/Rakefile +6 -0
- data/activefacts-examples.gemspec +26 -0
- data/cql/Address.cql +44 -0
- data/cql/Astronomy.cql +35 -0
- data/cql/Blog.cql +54 -0
- data/cql/CinemaBookings.cql +64 -0
- data/cql/CinemaTickets.cql +127 -0
- data/cql/CompanyDirectorEmployee.cql +56 -0
- data/cql/Death.cql +17 -0
- data/cql/Diplomacy.cql +48 -0
- data/cql/Genealogy.cql +98 -0
- data/cql/Health.cql +78 -0
- data/cql/Insurance.cql +320 -0
- data/cql/Marriage.cql +18 -0
- data/cql/Metamodel.cql +567 -0
- data/cql/Monogamy.cql +24 -0
- data/cql/MultiInheritance.cql +22 -0
- data/cql/MultipleSubtyping.cql +30 -0
- data/cql/NonRoleId.cql +14 -0
- data/cql/OddIdentifier.cql +18 -0
- data/cql/OilSupply.cql +53 -0
- data/cql/OneRoleNesting.cql +38 -0
- data/cql/OneToOnes.cql +17 -0
- data/cql/Orienteering.cql +111 -0
- data/cql/PartyModel.cql +38 -0
- data/cql/PersonPlaysGame.cql +18 -0
- data/cql/RedundantDependency.cql +34 -0
- data/cql/SchoolActivities.cql +33 -0
- data/cql/SeparateSubtype.cql +30 -0
- data/cql/ServiceDirector.cql +276 -0
- data/cql/SimplestUnary.cql +12 -0
- data/cql/Supervision.cql +34 -0
- data/cql/VenueSeating.cql +45 -0
- data/cql/WaiterTips.cql +33 -0
- data/cql/Warehousing.cql +101 -0
- data/cql/WindowInRoomInBldg.cql +28 -0
- data/cql/unit.cql +474 -0
- data/diagrams/json/Address.json +41 -0
- data/diagrams/json/Astronomy.json +31 -0
- data/diagrams/json/Blog.json +46 -0
- data/diagrams/json/CinemaBookings.json +53 -0
- data/diagrams/json/CinemaTickets.json +101 -0
- data/diagrams/json/CompanyDirectorEmployee.json +44 -0
- data/diagrams/json/Death.json +20 -0
- data/diagrams/json/Diplomacy.json +34 -0
- data/diagrams/json/Genealogy.json +78 -0
- data/diagrams/json/Insurance.json +259 -0
- data/diagrams/json/Marriage.json +21 -0
- data/diagrams/json/Metamodel.json +318 -0
- data/diagrams/json/Monogamy.json +22 -0
- data/diagrams/json/MultiInheritance.json +25 -0
- data/diagrams/json/MultipleSubtyping.json +22 -0
- data/diagrams/json/OilSupply.json +49 -0
- data/diagrams/json/OneRoleNesting.json +37 -0
- data/diagrams/json/Orienteering.json +94 -0
- data/diagrams/json/PersonPlaysGame.json +22 -0
- data/diagrams/json/RedundantDependency.json +33 -0
- data/diagrams/json/SchoolActivities.json +28 -0
- data/diagrams/json/SeparateSubtype.json +29 -0
- data/diagrams/json/SimplestUnary.json +15 -0
- data/diagrams/json/Supervision.json +27 -0
- data/diagrams/json/VenueSeating.json +40 -0
- data/diagrams/json/WaiterTips.json +29 -0
- data/diagrams/json/Warehousing.json +86 -0
- data/diagrams/json/WindowInRoomInBldg.json +31 -0
- data/images/Address.SQL.png +0 -0
- data/images/Address.png +0 -0
- data/images/Blog.png +0 -0
- data/images/CinemaBookings.png +0 -0
- data/images/CinemaTickets.png +0 -0
- data/images/CompanyDirectorEmployee.png +0 -0
- data/images/Death.png +0 -0
- data/images/Diplomacy.png +0 -0
- data/images/DumpMetamodel.bat +2 -0
- data/images/Genealogy.png +0 -0
- data/images/Insurance/Claim.png +0 -0
- data/images/Insurance/Insurance.png +0 -0
- data/images/Insurance/Person.png +0 -0
- data/images/Insurance/Policy.png +0 -0
- data/images/Insurance/Related.png +0 -0
- data/images/Insurance/VehicleIncident.png +0 -0
- data/images/Marriage.png +0 -0
- data/images/Metamodel/Concepts.png +0 -0
- data/images/Metamodel/Constraints.png +0 -0
- data/images/Metamodel/ContextNote.png +0 -0
- data/images/Metamodel/Diagrams.png +0 -0
- data/images/Metamodel/Language.png +0 -0
- data/images/Metamodel/Legacy.png +0 -0
- data/images/Metamodel/Objects.png +0 -0
- data/images/Metamodel/Populations.png +0 -0
- data/images/Metamodel/Query.png +0 -0
- data/images/Metamodel/Units.png +0 -0
- data/images/Metamodel/ValueConstraints.png +0 -0
- data/images/Metamodel/ValueTypes.png +0 -0
- data/images/MetamodelER.bcp +1 -0
- data/images/MetamodelER.pdf +0 -0
- data/images/MultiInheritance.png +0 -0
- data/images/NorthwindER.png +0 -0
- data/images/OilSupply.png +0 -0
- data/images/Orienteering/Administration.png +0 -0
- data/images/Orienteering/Registration.png +0 -0
- data/images/Orienteering/Scoring.png +0 -0
- data/images/PersonPlaysGame.png +0 -0
- data/images/RedundantDependency.png +0 -0
- data/images/SchoolActivities.png +0 -0
- data/images/SeparateSubtype.png +0 -0
- data/images/SimplestUnary.png +0 -0
- data/images/Supervision.png +0 -0
- data/images/VenueSeating.png +0 -0
- data/images/WaiterTips.png +0 -0
- data/images/Warehousing.png +0 -0
- data/images/WindowInRoomInBldg.png +0 -0
- data/metadata/json/Astronomy.json +175 -0
- data/metadata/json/CinemaBookings.json +354 -0
- data/metadata/json/CinemaTickets.json +768 -0
- data/metadata/json/CompanyDirectorEmployee.json +270 -0
- data/metadata/json/Diplomacy.json +186 -0
- data/metadata/json/Metamodel.json +3214 -0
- data/metadata/json/OilSupply.json +411 -0
- data/metadata/json/SeparateSubtype.json +157 -0
- data/metadata/json/Supervision.json +128 -0
- data/metadata/json/VenueSeating.json +209 -0
- data/orm/.gitignore +11 -0
- data/orm/Address.orm +1268 -0
- data/orm/Astronomy.orm +925 -0
- data/orm/Blog.orm +1711 -0
- data/orm/CinemaBookings.orm +1998 -0
- data/orm/CinemaTickets.orm +5060 -0
- data/orm/CompanyDirectorEmployee.orm +2094 -0
- data/orm/Death.orm +386 -0
- data/orm/Diplomacy.orm +1478 -0
- data/orm/ExampleModels2010.csproj +764 -0
- data/orm/ExampleModels2010.sln +16 -0
- data/orm/Genealogy.orm +3209 -0
- data/orm/Health.orm +2407 -0
- data/orm/Insurance.orm +12727 -0
- data/orm/Marriage.orm +493 -0
- data/orm/Metamodel.orm +20998 -0
- data/orm/Monogamy.orm +328 -0
- data/orm/MultiInheritance.orm +537 -0
- data/orm/MultipleSubtyping.orm +347 -0
- data/orm/OilSupply.orm +2533 -0
- data/orm/OneRoleNesting.orm +1237 -0
- data/orm/Orienteering.orm +3976 -0
- data/orm/PersonPlaysGame.orm +426 -0
- data/orm/RedundantDependency.orm +844 -0
- data/orm/SchoolActivities.orm +961 -0
- data/orm/SeparateSubtype.orm +821 -0
- data/orm/SimplestUnary.orm +172 -0
- data/orm/Supervision.orm +734 -0
- data/orm/VenueSeating.orm +1289 -0
- data/orm/WaiterTips.orm +789 -0
- data/orm/Warehousing.orm +3792 -0
- data/orm/WindowInRoomInBldg.orm +772 -0
- data/rails/models/Astronomy.models +17 -0
- data/rails/models/CinemaBookings.models +123 -0
- data/rails/models/CinemaTickets.models +192 -0
- data/rails/models/Diplomacy.models +126 -0
- data/rails/models/Metamodel.models +894 -0
- data/rails/models/OneRoleNesting.models +18 -0
- data/rails/models/SeparateSubtype.models +49 -0
- data/rails/models/VenueSeating.models +70 -0
- data/rails/schema/Astronomy.schema.rb +25 -0
- data/rails/schema/CinemaBookings.schema.rb +78 -0
- data/rails/schema/CinemaTickets.schema.rb +132 -0
- data/rails/schema/Diplomacy.schema.rb +74 -0
- data/rails/schema/Metamodel.schema.rb +538 -0
- data/rails/schema/OneRoleNesting.rb +20 -0
- data/rails/schema/SeparateSubtype.schema.rb +35 -0
- data/rails/schema/VenueSeating.schema.rb +46 -0
- data/rails/schema/Warehousing.schema.rb +145 -0
- data/ruby/Address.rb +68 -0
- data/ruby/Astronomy.rb +55 -0
- data/ruby/Blog.rb +84 -0
- data/ruby/CinemaBookings.rb +109 -0
- data/ruby/CinemaTickets.rb +218 -0
- data/ruby/CompanyDirectorEmployee.rb +73 -0
- data/ruby/Death.rb +26 -0
- data/ruby/Diplomacy.rb +59 -0
- data/ruby/Genealogy.rb +173 -0
- data/ruby/Insurance.rb +562 -0
- data/ruby/Marriage.rb +21 -0
- data/ruby/Metamodel.rb +621 -0
- data/ruby/Monogamy.rb +27 -0
- data/ruby/MultiInheritance.rb +38 -0
- data/ruby/OilSupply.rb +112 -0
- data/ruby/OneRoleNesting.rb +66 -0
- data/ruby/Orienteering.rb +216 -0
- data/ruby/PersonPlaysGame.rb +31 -0
- data/ruby/RedundantDependency.rb +53 -0
- data/ruby/SchoolActivities.rb +49 -0
- data/ruby/SeparateSubtype.rb +46 -0
- data/ruby/SimplestUnary.rb +10 -0
- data/ruby/Supervision.rb +33 -0
- data/ruby/TwoValues.rb +14 -0
- data/ruby/VenueSeating.rb +64 -0
- data/ruby/WaiterTips.rb +49 -0
- data/ruby/Warehousing.rb +167 -0
- data/ruby/WindowInRoomInBldg.rb +45 -0
- data/sql/server/Address.sql +40 -0
- data/sql/server/Astronomy.sql +36 -0
- data/sql/server/Blog.sql +78 -0
- data/sql/server/CinemaBookings.sql +95 -0
- data/sql/server/CinemaTickets.sql +191 -0
- data/sql/server/CompanyDirectorEmployee.sql +104 -0
- data/sql/server/Death.sql +11 -0
- data/sql/server/Diplomacy.sql +66 -0
- data/sql/server/Genealogy.sql +138 -0
- data/sql/server/Health.sql +169 -0
- data/sql/server/Insurance.sql +484 -0
- data/sql/server/Marriage.sql +30 -0
- data/sql/server/Metamodel.sql +1000 -0
- data/sql/server/Monogamy.sql +20 -0
- data/sql/server/MultiInheritance.sql +27 -0
- data/sql/server/OilSupply.sql +105 -0
- data/sql/server/OneRoleNesting.sql +29 -0
- data/sql/server/Orienteering.sql +186 -0
- data/sql/server/PersonPlaysGame.sql +9 -0
- data/sql/server/RedundantDependency.sql +54 -0
- data/sql/server/SchoolActivities.sql +30 -0
- data/sql/server/SeparateSubtype.sql +33 -0
- data/sql/server/SimplestUnary.sql +9 -0
- data/sql/server/Supervision.sql +30 -0
- data/sql/server/VenueSeating.sql +54 -0
- data/sql/server/WaiterTips.sql +31 -0
- data/sql/server/Warehousing.sql +203 -0
- data/sql/server/WindowInRoomInBldg.sql +13 -0
- data/transform/surrogate/Address.absorption +2 -0
- data/transform/surrogate/Blog.absorption +5 -0
- data/transform/surrogate/CinemaBookings.absorption +7 -0
- data/transform/surrogate/CompanyDirectorEmployee.absorption +7 -0
- data/transform/surrogate/Death.absorption +1 -0
- data/transform/surrogate/Diplomacy-revised.absorption +6 -0
- data/transform/surrogate/Diplomacy.absorption +6 -0
- data/transform/surrogate/Genealogy.absorption +8 -0
- data/transform/surrogate/Insurance.absorption +18 -0
- data/transform/surrogate/Marriage.absorption +2 -0
- data/transform/surrogate/Metamodel.absorption +25 -0
- data/transform/surrogate/Monogamy.absorption +1 -0
- data/transform/surrogate/MultiInheritance.absorption +1 -0
- data/transform/surrogate/MultipleSubtyping.absorption +1 -0
- data/transform/surrogate/OilSupply.absorption +8 -0
- data/transform/surrogate/OneRoleNesting.absorption +1 -0
- data/transform/surrogate/Orienteering.absorption +11 -0
- data/transform/surrogate/PersonPlaysGame.absorption +1 -0
- data/transform/surrogate/RedundantDependency.absorption +3 -0
- data/transform/surrogate/SchoolActivities.absorption +3 -0
- data/transform/surrogate/SeparateSubtype.absorption +3 -0
- data/transform/surrogate/SimplestUnary.absorption +1 -0
- data/transform/surrogate/Supervision.absorption +2 -0
- data/transform/surrogate/WaiterTips.absorption +3 -0
- data/transform/surrogate/Warehousing.absorption +12 -0
- data/transform/surrogate/WindowInRoomInBldg.absorption +1 -0
- data/transform/surrogate/unit.absorption +0 -0
- metadata +374 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
CREATE TABLE AllocatableCinemaSection (
|
|
2
|
+
-- AllocatableCinemaSection involves Cinema and Cinema has Cinema ID,
|
|
3
|
+
CinemaID int NOT NULL,
|
|
4
|
+
-- AllocatableCinemaSection involves Section and Section has Section Name,
|
|
5
|
+
SectionName varchar NOT NULL,
|
|
6
|
+
PRIMARY KEY(CinemaID, SectionName)
|
|
7
|
+
)
|
|
8
|
+
GO
|
|
9
|
+
|
|
10
|
+
CREATE TABLE Booking (
|
|
11
|
+
-- maybe tickets for Booking are being mailed to Address and Address has Address Text,
|
|
12
|
+
AddressText text NULL,
|
|
13
|
+
-- Booking has Booking Nr,
|
|
14
|
+
BookingNr int NOT NULL,
|
|
15
|
+
-- maybe Booking has Collection Code,
|
|
16
|
+
CollectionCode int NULL,
|
|
17
|
+
-- Booking involves Number,
|
|
18
|
+
Number smallint NOT NULL CHECK(Number >= 1),
|
|
19
|
+
-- Booking involves Person and Person has Person ID,
|
|
20
|
+
PersonID int NOT NULL,
|
|
21
|
+
-- maybe Booking is for seats in Section and Section has Section Name,
|
|
22
|
+
SectionName varchar NULL,
|
|
23
|
+
-- Booking involves Session and Session involves Cinema and Cinema has Cinema ID,
|
|
24
|
+
SessionCinemaID int NOT NULL,
|
|
25
|
+
-- Booking involves Session and Session involves Session Time and Session Time is on Day,
|
|
26
|
+
SessionTimeDay int NOT NULL,
|
|
27
|
+
-- Booking involves Session and Session involves Session Time and Session Time is at Hour,
|
|
28
|
+
SessionTimeHour int NOT NULL,
|
|
29
|
+
-- Booking involves Session and Session involves Session Time and Session Time is at Minute,
|
|
30
|
+
SessionTimeMinute int NOT NULL,
|
|
31
|
+
-- Booking involves Session and Session involves Session Time and Session Time is in Month and Month has Month Nr,
|
|
32
|
+
SessionTimeMonthNr int NOT NULL,
|
|
33
|
+
-- Booking involves Session and Session involves Session Time and Session Time is in Year and Year has Year Nr,
|
|
34
|
+
SessionTimeYearNr int NOT NULL,
|
|
35
|
+
-- tickets for Booking have been issued Boolean,
|
|
36
|
+
TicketsForHaveBeenIssued bit NULL,
|
|
37
|
+
PRIMARY KEY(BookingNr),
|
|
38
|
+
UNIQUE(PersonID, SessionCinemaID, SessionTimeYearNr, SessionTimeMonthNr, SessionTimeDay, SessionTimeHour, SessionTimeMinute)
|
|
39
|
+
)
|
|
40
|
+
GO
|
|
41
|
+
|
|
42
|
+
CREATE TABLE Cinema (
|
|
43
|
+
-- Cinema has Cinema ID,
|
|
44
|
+
CinemaID int IDENTITY NOT NULL,
|
|
45
|
+
-- Cinema has Name,
|
|
46
|
+
Name varchar NOT NULL,
|
|
47
|
+
PRIMARY KEY(CinemaID),
|
|
48
|
+
UNIQUE(Name)
|
|
49
|
+
)
|
|
50
|
+
GO
|
|
51
|
+
|
|
52
|
+
CREATE TABLE Film (
|
|
53
|
+
-- Film has Film ID,
|
|
54
|
+
FilmID int IDENTITY NOT NULL,
|
|
55
|
+
-- Film has Name,
|
|
56
|
+
Name varchar NOT NULL,
|
|
57
|
+
-- maybe Film was made in Year and Year has Year Nr,
|
|
58
|
+
YearNr int NULL CHECK((YearNr >= 1900 AND YearNr <= 9999)),
|
|
59
|
+
PRIMARY KEY(FilmID)
|
|
60
|
+
)
|
|
61
|
+
GO
|
|
62
|
+
|
|
63
|
+
CREATE VIEW dbo.Film_NameYearNr (Name, YearNr) WITH SCHEMABINDING AS
|
|
64
|
+
SELECT Name, YearNr FROM dbo.Film
|
|
65
|
+
WHERE YearNr IS NOT NULL
|
|
66
|
+
GO
|
|
67
|
+
|
|
68
|
+
CREATE UNIQUE CLUSTERED INDEX IX_FilmByNameYearNr ON dbo.Film_NameYearNr(Name, YearNr)
|
|
69
|
+
GO
|
|
70
|
+
|
|
71
|
+
CREATE TABLE Person (
|
|
72
|
+
-- maybe Person has Encrypted Password,
|
|
73
|
+
EncryptedPassword varchar NULL,
|
|
74
|
+
-- maybe Person has login-Name,
|
|
75
|
+
LoginName varchar NULL,
|
|
76
|
+
-- Person has Person ID,
|
|
77
|
+
PersonID int IDENTITY NOT NULL,
|
|
78
|
+
PRIMARY KEY(PersonID)
|
|
79
|
+
)
|
|
80
|
+
GO
|
|
81
|
+
|
|
82
|
+
CREATE VIEW dbo.Person_LoginName (LoginName) WITH SCHEMABINDING AS
|
|
83
|
+
SELECT LoginName FROM dbo.Person
|
|
84
|
+
WHERE LoginName IS NOT NULL
|
|
85
|
+
GO
|
|
86
|
+
|
|
87
|
+
CREATE UNIQUE CLUSTERED INDEX IX_PersonByLoginName ON dbo.Person_LoginName(LoginName)
|
|
88
|
+
GO
|
|
89
|
+
|
|
90
|
+
CREATE TABLE PlacesPaid (
|
|
91
|
+
-- Places Paid involves Booking and Booking has Booking Nr,
|
|
92
|
+
BookingNr int NOT NULL,
|
|
93
|
+
-- Places Paid involves Number,
|
|
94
|
+
Number smallint NOT NULL CHECK(Number >= 1),
|
|
95
|
+
-- Places Paid involves Payment Method and Payment Method has Payment Method Code,
|
|
96
|
+
PaymentMethodCode varchar NOT NULL CHECK(PaymentMethodCode = 'Card' OR PaymentMethodCode = 'Cash' OR PaymentMethodCode = 'Gift Voucher' OR PaymentMethodCode = 'Loyalty Voucher'),
|
|
97
|
+
PRIMARY KEY(BookingNr, PaymentMethodCode),
|
|
98
|
+
FOREIGN KEY (BookingNr) REFERENCES Booking (BookingNr)
|
|
99
|
+
)
|
|
100
|
+
GO
|
|
101
|
+
|
|
102
|
+
CREATE TABLE Seat (
|
|
103
|
+
-- Seat is in Row and Row is in Cinema and Cinema has Cinema ID,
|
|
104
|
+
RowCinemaID int NOT NULL,
|
|
105
|
+
-- Seat is in Row and Row has Row Nr,
|
|
106
|
+
RowNr char(2) NOT NULL,
|
|
107
|
+
-- Seat has Seat Number,
|
|
108
|
+
SeatNumber smallint NOT NULL,
|
|
109
|
+
-- maybe Seat is in Section and Section has Section Name,
|
|
110
|
+
SectionName varchar NULL,
|
|
111
|
+
PRIMARY KEY(RowCinemaID, RowNr, SeatNumber),
|
|
112
|
+
FOREIGN KEY (RowCinemaID) REFERENCES Cinema (CinemaID)
|
|
113
|
+
)
|
|
114
|
+
GO
|
|
115
|
+
|
|
116
|
+
CREATE TABLE SeatAllocation (
|
|
117
|
+
-- Seat Allocation involves Seat and Seat has Seat Number,
|
|
118
|
+
AllocatedSeatNumber smallint NOT NULL,
|
|
119
|
+
-- Seat Allocation involves Seat and Seat is in Row and Row is in Cinema and Cinema has Cinema ID,
|
|
120
|
+
AllocatedSeatRowCinemaID int NOT NULL,
|
|
121
|
+
-- Seat Allocation involves Seat and Seat is in Row and Row has Row Nr,
|
|
122
|
+
AllocatedSeatRowNr char(2) NOT NULL,
|
|
123
|
+
-- Seat Allocation involves Booking and Booking has Booking Nr,
|
|
124
|
+
BookingNr int NOT NULL,
|
|
125
|
+
PRIMARY KEY(BookingNr, AllocatedSeatRowCinemaID, AllocatedSeatRowNr, AllocatedSeatNumber),
|
|
126
|
+
FOREIGN KEY (BookingNr) REFERENCES Booking (BookingNr),
|
|
127
|
+
FOREIGN KEY (AllocatedSeatRowCinemaID, AllocatedSeatRowNr, AllocatedSeatNumber) REFERENCES Seat (RowCinemaID, RowNr, SeatNumber)
|
|
128
|
+
)
|
|
129
|
+
GO
|
|
130
|
+
|
|
131
|
+
CREATE TABLE Session (
|
|
132
|
+
-- Session involves Cinema and Cinema has Cinema ID,
|
|
133
|
+
CinemaID int NOT NULL,
|
|
134
|
+
-- Session involves Film and Film has Film ID,
|
|
135
|
+
FilmID int NOT NULL,
|
|
136
|
+
-- Session is high-demand Boolean,
|
|
137
|
+
IsHighDemand bit NULL,
|
|
138
|
+
-- Session involves Session Time and Session Time is on Day,
|
|
139
|
+
SessionTimeDay int NOT NULL CHECK((SessionTimeDay >= 1 AND SessionTimeDay <= 31)),
|
|
140
|
+
-- Session involves Session Time and Session Time is at Hour,
|
|
141
|
+
SessionTimeHour int NOT NULL CHECK((SessionTimeHour >= 0 AND SessionTimeHour <= 23)),
|
|
142
|
+
-- Session involves Session Time and Session Time is at Minute,
|
|
143
|
+
SessionTimeMinute int NOT NULL CHECK((SessionTimeMinute >= 0 AND SessionTimeMinute <= 59)),
|
|
144
|
+
-- Session involves Session Time and Session Time is in Month and Month has Month Nr,
|
|
145
|
+
SessionTimeMonthNr int NOT NULL CHECK((SessionTimeMonthNr >= 1 AND SessionTimeMonthNr <= 12)),
|
|
146
|
+
-- Session involves Session Time and Session Time is in Year and Year has Year Nr,
|
|
147
|
+
SessionTimeYearNr int NOT NULL CHECK((SessionTimeYearNr >= 1900 AND SessionTimeYearNr <= 9999)),
|
|
148
|
+
-- Session uses allocated seating Boolean,
|
|
149
|
+
UsesAllocatedSeating bit NULL,
|
|
150
|
+
PRIMARY KEY(CinemaID, SessionTimeYearNr, SessionTimeMonthNr, SessionTimeDay, SessionTimeHour, SessionTimeMinute),
|
|
151
|
+
FOREIGN KEY (CinemaID) REFERENCES Cinema (CinemaID),
|
|
152
|
+
FOREIGN KEY (FilmID) REFERENCES Film (FilmID)
|
|
153
|
+
)
|
|
154
|
+
GO
|
|
155
|
+
|
|
156
|
+
CREATE TABLE TicketPricing (
|
|
157
|
+
-- Ticket Pricing involves Cinema and Cinema has Cinema ID,
|
|
158
|
+
CinemaID int NOT NULL,
|
|
159
|
+
-- Ticket Pricing involves High Demand,
|
|
160
|
+
HighDemand Boolean NOT NULL,
|
|
161
|
+
-- Ticket Pricing involves Price,
|
|
162
|
+
Price decimal NOT NULL,
|
|
163
|
+
-- Ticket Pricing involves Section and Section has Section Name,
|
|
164
|
+
SectionName varchar NOT NULL,
|
|
165
|
+
-- Ticket Pricing involves Session Time and Session Time is on Day,
|
|
166
|
+
SessionTimeDay int NOT NULL CHECK((SessionTimeDay >= 1 AND SessionTimeDay <= 31)),
|
|
167
|
+
-- Ticket Pricing involves Session Time and Session Time is at Hour,
|
|
168
|
+
SessionTimeHour int NOT NULL CHECK((SessionTimeHour >= 0 AND SessionTimeHour <= 23)),
|
|
169
|
+
-- Ticket Pricing involves Session Time and Session Time is at Minute,
|
|
170
|
+
SessionTimeMinute int NOT NULL CHECK((SessionTimeMinute >= 0 AND SessionTimeMinute <= 59)),
|
|
171
|
+
-- Ticket Pricing involves Session Time and Session Time is in Month and Month has Month Nr,
|
|
172
|
+
SessionTimeMonthNr int NOT NULL CHECK((SessionTimeMonthNr >= 1 AND SessionTimeMonthNr <= 12)),
|
|
173
|
+
-- Ticket Pricing involves Session Time and Session Time is in Year and Year has Year Nr,
|
|
174
|
+
SessionTimeYearNr int NOT NULL CHECK((SessionTimeYearNr >= 1900 AND SessionTimeYearNr <= 9999)),
|
|
175
|
+
PRIMARY KEY(SessionTimeYearNr, SessionTimeMonthNr, SessionTimeDay, SessionTimeHour, SessionTimeMinute, CinemaID, SectionName, HighDemand),
|
|
176
|
+
FOREIGN KEY (CinemaID) REFERENCES Cinema (CinemaID)
|
|
177
|
+
)
|
|
178
|
+
GO
|
|
179
|
+
|
|
180
|
+
ALTER TABLE AllocatableCinemaSection
|
|
181
|
+
ADD FOREIGN KEY (CinemaID) REFERENCES Cinema (CinemaID)
|
|
182
|
+
GO
|
|
183
|
+
|
|
184
|
+
ALTER TABLE Booking
|
|
185
|
+
ADD FOREIGN KEY (PersonID) REFERENCES Person (PersonID)
|
|
186
|
+
GO
|
|
187
|
+
|
|
188
|
+
ALTER TABLE Booking
|
|
189
|
+
ADD FOREIGN KEY (SessionCinemaID, SessionTimeYearNr, SessionTimeMonthNr, SessionTimeDay, SessionTimeHour, SessionTimeMinute) REFERENCES Session (CinemaID, SessionTimeYearNr, SessionTimeMonthNr, SessionTimeDay, SessionTimeHour, SessionTimeMinute)
|
|
190
|
+
GO
|
|
191
|
+
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
CREATE TABLE Attendance (
|
|
2
|
+
-- Attendance involves Person and maybe Person is called family-Name,
|
|
3
|
+
AttendeeFamilyName varchar(48) NULL,
|
|
4
|
+
-- Attendance involves Person and Person has given-Name,
|
|
5
|
+
AttendeeGivenName varchar(48) NOT NULL,
|
|
6
|
+
-- Attendance involves Meeting and Meeting is held by Company and Company is called Company Name,
|
|
7
|
+
MeetingCompanyName varchar(48) NOT NULL,
|
|
8
|
+
-- Attendance involves Meeting and Meeting is held on Date,
|
|
9
|
+
MeetingDate datetime NOT NULL,
|
|
10
|
+
-- Attendance involves Meeting and Meeting is board meeting,
|
|
11
|
+
MeetingIsBoardMeeting bit NULL,
|
|
12
|
+
UNIQUE(AttendeeGivenName, AttendeeFamilyName, MeetingCompanyName, MeetingDate, MeetingIsBoardMeeting)
|
|
13
|
+
)
|
|
14
|
+
GO
|
|
15
|
+
|
|
16
|
+
CREATE TABLE Company (
|
|
17
|
+
-- Company is called Company Name,
|
|
18
|
+
CompanyName varchar(48) NOT NULL,
|
|
19
|
+
-- Company is listed Boolean,
|
|
20
|
+
IsListed bit NULL,
|
|
21
|
+
PRIMARY KEY(CompanyName)
|
|
22
|
+
)
|
|
23
|
+
GO
|
|
24
|
+
|
|
25
|
+
CREATE TABLE Directorship (
|
|
26
|
+
-- Directorship began on appointment-Date,
|
|
27
|
+
AppointmentDate datetime NOT NULL,
|
|
28
|
+
-- Directorship involves Company and Company is called Company Name,
|
|
29
|
+
CompanyName varchar(48) NOT NULL,
|
|
30
|
+
-- Directorship involves Person and maybe Person is called family-Name,
|
|
31
|
+
DirectorFamilyName varchar(48) NULL,
|
|
32
|
+
-- Directorship involves Person and Person has given-Name,
|
|
33
|
+
DirectorGivenName varchar(48) NOT NULL,
|
|
34
|
+
UNIQUE(DirectorGivenName, DirectorFamilyName, CompanyName),
|
|
35
|
+
FOREIGN KEY (CompanyName) REFERENCES Company (CompanyName)
|
|
36
|
+
)
|
|
37
|
+
GO
|
|
38
|
+
|
|
39
|
+
CREATE TABLE Employee (
|
|
40
|
+
-- Employee works at Company and Company is called Company Name,
|
|
41
|
+
CompanyName varchar(48) NOT NULL,
|
|
42
|
+
-- Employee has Employee Nr,
|
|
43
|
+
EmployeeNr int NOT NULL,
|
|
44
|
+
-- maybe Employee is a Manager and Manager is ceo Boolean,
|
|
45
|
+
ManagerIsCeo bit NULL,
|
|
46
|
+
-- maybe Employee is supervised by Manager and Manager is a kind of Employee and Employee has Employee Nr,
|
|
47
|
+
ManagerNr int NULL,
|
|
48
|
+
PRIMARY KEY(EmployeeNr),
|
|
49
|
+
FOREIGN KEY (CompanyName) REFERENCES Company (CompanyName),
|
|
50
|
+
FOREIGN KEY (ManagerNr) REFERENCES Employee (EmployeeNr)
|
|
51
|
+
)
|
|
52
|
+
GO
|
|
53
|
+
|
|
54
|
+
CREATE TABLE Employment (
|
|
55
|
+
-- Employment involves Employee and Employee has Employee Nr,
|
|
56
|
+
EmployeeNr int NOT NULL,
|
|
57
|
+
-- Employment involves Person and maybe Person is called family-Name,
|
|
58
|
+
PersonFamilyName varchar(48) NULL,
|
|
59
|
+
-- Employment involves Person and Person has given-Name,
|
|
60
|
+
PersonGivenName varchar(48) NOT NULL,
|
|
61
|
+
UNIQUE(PersonGivenName, PersonFamilyName, EmployeeNr),
|
|
62
|
+
FOREIGN KEY (EmployeeNr) REFERENCES Employee (EmployeeNr)
|
|
63
|
+
)
|
|
64
|
+
GO
|
|
65
|
+
|
|
66
|
+
CREATE TABLE Meeting (
|
|
67
|
+
-- Meeting is held by Company and Company is called Company Name,
|
|
68
|
+
CompanyName varchar(48) NOT NULL,
|
|
69
|
+
-- Meeting is held on Date,
|
|
70
|
+
Date datetime NOT NULL,
|
|
71
|
+
-- Meeting is board meeting,
|
|
72
|
+
IsBoardMeeting bit NULL,
|
|
73
|
+
UNIQUE(CompanyName, Date, IsBoardMeeting),
|
|
74
|
+
FOREIGN KEY (CompanyName) REFERENCES Company (CompanyName)
|
|
75
|
+
)
|
|
76
|
+
GO
|
|
77
|
+
|
|
78
|
+
CREATE TABLE Person (
|
|
79
|
+
-- maybe Person was born on birth-Date,
|
|
80
|
+
BirthDate datetime NULL CHECK(BirthDate >= '1900/01/01'),
|
|
81
|
+
-- maybe Person is called family-Name,
|
|
82
|
+
FamilyName varchar(48) NULL,
|
|
83
|
+
-- Person has given-Name,
|
|
84
|
+
GivenName varchar(48) NOT NULL,
|
|
85
|
+
UNIQUE(GivenName, FamilyName)
|
|
86
|
+
)
|
|
87
|
+
GO
|
|
88
|
+
|
|
89
|
+
ALTER TABLE Attendance
|
|
90
|
+
ADD FOREIGN KEY (MeetingCompanyName, MeetingDate, MeetingIsBoardMeeting) REFERENCES Meeting (CompanyName, Date, IsBoardMeeting)
|
|
91
|
+
GO
|
|
92
|
+
|
|
93
|
+
ALTER TABLE Attendance
|
|
94
|
+
ADD FOREIGN KEY (AttendeeGivenName, AttendeeFamilyName) REFERENCES Person (GivenName, FamilyName)
|
|
95
|
+
GO
|
|
96
|
+
|
|
97
|
+
ALTER TABLE Directorship
|
|
98
|
+
ADD FOREIGN KEY (DirectorGivenName, DirectorFamilyName) REFERENCES Person (GivenName, FamilyName)
|
|
99
|
+
GO
|
|
100
|
+
|
|
101
|
+
ALTER TABLE Employment
|
|
102
|
+
ADD FOREIGN KEY (PersonGivenName, PersonFamilyName) REFERENCES Person (GivenName, FamilyName)
|
|
103
|
+
GO
|
|
104
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
CREATE TABLE Person (
|
|
2
|
+
-- Person is involved in Death and maybe Death was due to Cause Of Death,
|
|
3
|
+
DeathCauseOfDeath varchar NULL,
|
|
4
|
+
-- Person is involved in Death,
|
|
5
|
+
IsDead bit NULL,
|
|
6
|
+
-- Person has Person Name,
|
|
7
|
+
PersonName varchar(40) NOT NULL,
|
|
8
|
+
PRIMARY KEY(PersonName)
|
|
9
|
+
)
|
|
10
|
+
GO
|
|
11
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
CREATE TABLE Country (
|
|
2
|
+
-- Country has CountryName,
|
|
3
|
+
CountryName varchar NOT NULL,
|
|
4
|
+
PRIMARY KEY(CountryName)
|
|
5
|
+
)
|
|
6
|
+
GO
|
|
7
|
+
|
|
8
|
+
CREATE TABLE Diplomat (
|
|
9
|
+
-- Diplomat has DiplomatName,
|
|
10
|
+
DiplomatName varchar NOT NULL,
|
|
11
|
+
-- Diplomat represents Country and Country has CountryName,
|
|
12
|
+
RepresentedCountryName varchar NOT NULL,
|
|
13
|
+
-- Diplomat serves in Country and Country has CountryName,
|
|
14
|
+
ServedCountryName varchar NOT NULL,
|
|
15
|
+
PRIMARY KEY(DiplomatName),
|
|
16
|
+
FOREIGN KEY (RepresentedCountryName) REFERENCES Country (CountryName),
|
|
17
|
+
FOREIGN KEY (ServedCountryName) REFERENCES Country (CountryName)
|
|
18
|
+
)
|
|
19
|
+
GO
|
|
20
|
+
|
|
21
|
+
CREATE TABLE Fluency (
|
|
22
|
+
-- Fluency involves Diplomat and Diplomat has DiplomatName,
|
|
23
|
+
DiplomatName varchar NOT NULL,
|
|
24
|
+
-- Fluency involves Language and Language has LanguageName,
|
|
25
|
+
LanguageName varchar NOT NULL,
|
|
26
|
+
PRIMARY KEY(DiplomatName, LanguageName),
|
|
27
|
+
FOREIGN KEY (DiplomatName) REFERENCES Diplomat (DiplomatName)
|
|
28
|
+
)
|
|
29
|
+
GO
|
|
30
|
+
|
|
31
|
+
CREATE TABLE Language (
|
|
32
|
+
-- Language has LanguageName,
|
|
33
|
+
LanguageName varchar NOT NULL,
|
|
34
|
+
PRIMARY KEY(LanguageName)
|
|
35
|
+
)
|
|
36
|
+
GO
|
|
37
|
+
|
|
38
|
+
CREATE TABLE LanguageUse (
|
|
39
|
+
-- LanguageUse involves Country and Country has CountryName,
|
|
40
|
+
CountryName varchar NOT NULL,
|
|
41
|
+
-- LanguageUse involves Language and Language has LanguageName,
|
|
42
|
+
LanguageName varchar NOT NULL,
|
|
43
|
+
PRIMARY KEY(LanguageName, CountryName),
|
|
44
|
+
FOREIGN KEY (CountryName) REFERENCES Country (CountryName),
|
|
45
|
+
FOREIGN KEY (LanguageName) REFERENCES Language (LanguageName)
|
|
46
|
+
)
|
|
47
|
+
GO
|
|
48
|
+
|
|
49
|
+
CREATE TABLE Representation (
|
|
50
|
+
-- Representation involves Ambassador and Ambassador is a kind of Diplomat and Diplomat has DiplomatName,
|
|
51
|
+
AmbassadorName varchar NOT NULL,
|
|
52
|
+
-- Representation involves Country and Country has CountryName,
|
|
53
|
+
CountryName varchar NOT NULL,
|
|
54
|
+
-- Representation involves Country and Country has CountryName,
|
|
55
|
+
RepresentedCountryName varchar NOT NULL,
|
|
56
|
+
PRIMARY KEY(RepresentedCountryName, CountryName),
|
|
57
|
+
FOREIGN KEY (CountryName) REFERENCES Country (CountryName),
|
|
58
|
+
FOREIGN KEY (RepresentedCountryName) REFERENCES Country (CountryName),
|
|
59
|
+
FOREIGN KEY (AmbassadorName) REFERENCES Diplomat (DiplomatName)
|
|
60
|
+
)
|
|
61
|
+
GO
|
|
62
|
+
|
|
63
|
+
ALTER TABLE Fluency
|
|
64
|
+
ADD FOREIGN KEY (LanguageName) REFERENCES Language (LanguageName)
|
|
65
|
+
GO
|
|
66
|
+
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
CREATE TABLE Event (
|
|
2
|
+
-- maybe Event is certified by Certificate,
|
|
3
|
+
Certificate varchar(64) NULL,
|
|
4
|
+
-- maybe Event occurred on Event Date and maybe Event Date occurred on Day,
|
|
5
|
+
EventDateDay int NULL CHECK((EventDateDay >= 1 AND EventDateDay <= 31)),
|
|
6
|
+
-- maybe Event occurred on Event Date and maybe Event Date wasnt after max-Year,
|
|
7
|
+
EventDateMaxYear int NULL,
|
|
8
|
+
-- maybe Event occurred on Event Date and maybe Event Date wasnt before min-Year,
|
|
9
|
+
EventDateMinYear int NULL,
|
|
10
|
+
-- maybe Event occurred on Event Date and maybe Event Date occurred in Month,
|
|
11
|
+
EventDateMonth int NULL CHECK((EventDateMonth >= 1 AND EventDateMonth <= 12)),
|
|
12
|
+
-- Event has Event ID,
|
|
13
|
+
EventID int IDENTITY NOT NULL,
|
|
14
|
+
-- maybe Event occurred at Event Location,
|
|
15
|
+
EventLocation varchar(128) NULL,
|
|
16
|
+
-- maybe Event is of Event Type and Event Type has Event Type ID,
|
|
17
|
+
EventTypeID int NULL,
|
|
18
|
+
-- maybe Event was confirmed by Official,
|
|
19
|
+
Official varchar(64) NULL,
|
|
20
|
+
PRIMARY KEY(EventID)
|
|
21
|
+
)
|
|
22
|
+
GO
|
|
23
|
+
|
|
24
|
+
CREATE TABLE EventType (
|
|
25
|
+
-- Event Type has Event Type ID,
|
|
26
|
+
EventTypeID int IDENTITY NOT NULL,
|
|
27
|
+
-- Event Type is called Event Type Name,
|
|
28
|
+
EventTypeName varchar(16) NOT NULL CHECK(EventTypeName = 'Birth' OR EventTypeName = 'Burial' OR EventTypeName = 'Christening' OR EventTypeName = 'Death' OR EventTypeName = 'Divorce' OR EventTypeName = 'Marriage'),
|
|
29
|
+
PRIMARY KEY(EventTypeID),
|
|
30
|
+
UNIQUE(EventTypeName)
|
|
31
|
+
)
|
|
32
|
+
GO
|
|
33
|
+
|
|
34
|
+
CREATE TABLE Friendship (
|
|
35
|
+
-- Friendship is confirmed Boolean,
|
|
36
|
+
IsConfirmed bit NULL,
|
|
37
|
+
-- Friendship involves User and User has User ID,
|
|
38
|
+
OtherUserID int NOT NULL,
|
|
39
|
+
-- Friendship involves User and User has User ID,
|
|
40
|
+
UserID int NOT NULL,
|
|
41
|
+
PRIMARY KEY(UserID, OtherUserID)
|
|
42
|
+
)
|
|
43
|
+
GO
|
|
44
|
+
|
|
45
|
+
CREATE TABLE Participation (
|
|
46
|
+
-- Participation involves Event and Event has Event ID,
|
|
47
|
+
EventID int NOT NULL,
|
|
48
|
+
-- Participation involves Person and Person has Person ID,
|
|
49
|
+
PersonID int NOT NULL,
|
|
50
|
+
-- Participation involves Role and Role has Role ID,
|
|
51
|
+
RoleID int NOT NULL,
|
|
52
|
+
-- Participation involves Source and Source has Source ID,
|
|
53
|
+
SourceID int NOT NULL,
|
|
54
|
+
PRIMARY KEY(PersonID, RoleID, EventID, SourceID),
|
|
55
|
+
FOREIGN KEY (EventID) REFERENCES Event (EventID)
|
|
56
|
+
)
|
|
57
|
+
GO
|
|
58
|
+
|
|
59
|
+
CREATE TABLE Person (
|
|
60
|
+
-- maybe Person lives at Address,
|
|
61
|
+
Address varchar(128) NULL,
|
|
62
|
+
-- maybe Person has Email,
|
|
63
|
+
Email varchar(64) NULL,
|
|
64
|
+
-- maybe Person is called family-Name,
|
|
65
|
+
FamilyName varchar(128) NULL,
|
|
66
|
+
-- maybe Person is of Gender,
|
|
67
|
+
Gender char(1) NULL CHECK(Gender = 'F' OR Gender = 'M'),
|
|
68
|
+
-- maybe Person is called given-Name,
|
|
69
|
+
GivenName varchar(128) NULL,
|
|
70
|
+
-- maybe Person is employed in Occupation,
|
|
71
|
+
Occupation varchar(128) NULL,
|
|
72
|
+
-- Person has Person ID,
|
|
73
|
+
PersonID int IDENTITY NOT NULL,
|
|
74
|
+
-- maybe Person has preferred-Picture,
|
|
75
|
+
PreferredPicture image NULL,
|
|
76
|
+
PRIMARY KEY(PersonID)
|
|
77
|
+
)
|
|
78
|
+
GO
|
|
79
|
+
|
|
80
|
+
CREATE TABLE Role (
|
|
81
|
+
-- Role is called Event Role Name,
|
|
82
|
+
EventRoleName varchar NOT NULL CHECK(EventRoleName = 'Celebrant' OR EventRoleName = 'Father' OR EventRoleName = 'Husband' OR EventRoleName = 'Mother' OR EventRoleName = 'Subject' OR EventRoleName = 'Wife'),
|
|
83
|
+
-- Role has Role ID,
|
|
84
|
+
RoleID int IDENTITY NOT NULL,
|
|
85
|
+
PRIMARY KEY(RoleID),
|
|
86
|
+
UNIQUE(EventRoleName)
|
|
87
|
+
)
|
|
88
|
+
GO
|
|
89
|
+
|
|
90
|
+
CREATE TABLE Source (
|
|
91
|
+
-- Source has Source ID,
|
|
92
|
+
SourceID int IDENTITY NOT NULL,
|
|
93
|
+
-- Source has Source Name,
|
|
94
|
+
SourceName varchar(128) NOT NULL,
|
|
95
|
+
-- Source was provided by User and User has User ID,
|
|
96
|
+
UserID int NOT NULL,
|
|
97
|
+
PRIMARY KEY(SourceID),
|
|
98
|
+
UNIQUE(SourceName)
|
|
99
|
+
)
|
|
100
|
+
GO
|
|
101
|
+
|
|
102
|
+
CREATE TABLE [User] (
|
|
103
|
+
-- maybe User has Email,
|
|
104
|
+
Email varchar(64) NULL,
|
|
105
|
+
-- User has User ID,
|
|
106
|
+
UserID int IDENTITY NOT NULL,
|
|
107
|
+
PRIMARY KEY(UserID)
|
|
108
|
+
)
|
|
109
|
+
GO
|
|
110
|
+
|
|
111
|
+
ALTER TABLE Event
|
|
112
|
+
ADD FOREIGN KEY (EventTypeID) REFERENCES EventType (EventTypeID)
|
|
113
|
+
GO
|
|
114
|
+
|
|
115
|
+
ALTER TABLE Friendship
|
|
116
|
+
ADD FOREIGN KEY (OtherUserID) REFERENCES [User] (UserID)
|
|
117
|
+
GO
|
|
118
|
+
|
|
119
|
+
ALTER TABLE Friendship
|
|
120
|
+
ADD FOREIGN KEY (UserID) REFERENCES [User] (UserID)
|
|
121
|
+
GO
|
|
122
|
+
|
|
123
|
+
ALTER TABLE Participation
|
|
124
|
+
ADD FOREIGN KEY (PersonID) REFERENCES Person (PersonID)
|
|
125
|
+
GO
|
|
126
|
+
|
|
127
|
+
ALTER TABLE Participation
|
|
128
|
+
ADD FOREIGN KEY (RoleID) REFERENCES Role (RoleID)
|
|
129
|
+
GO
|
|
130
|
+
|
|
131
|
+
ALTER TABLE Participation
|
|
132
|
+
ADD FOREIGN KEY (SourceID) REFERENCES Source (SourceID)
|
|
133
|
+
GO
|
|
134
|
+
|
|
135
|
+
ALTER TABLE Source
|
|
136
|
+
ADD FOREIGN KEY (UserID) REFERENCES [User] (UserID)
|
|
137
|
+
GO
|
|
138
|
+
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
CREATE TABLE AvailableCoverage (
|
|
2
|
+
-- Available Coverage involves Coverage Type and Coverage Type has Coverage Type Name,
|
|
3
|
+
CoverageTypeName varchar NOT NULL,
|
|
4
|
+
-- Available Coverage involves Product Offering and Product Offering has Product Offering Name,
|
|
5
|
+
ProductOfferingName varchar NOT NULL,
|
|
6
|
+
PRIMARY KEY(CoverageTypeName, ProductOfferingName)
|
|
7
|
+
)
|
|
8
|
+
GO
|
|
9
|
+
|
|
10
|
+
CREATE TABLE Claim (
|
|
11
|
+
-- Claim has Claim Number,
|
|
12
|
+
ClaimNumber Int NOT NULL,
|
|
13
|
+
PRIMARY KEY(ClaimNumber)
|
|
14
|
+
)
|
|
15
|
+
GO
|
|
16
|
+
|
|
17
|
+
CREATE TABLE ClaimPayment (
|
|
18
|
+
-- Claim Payment is for Claim Details and Claim Details involves Claim and Claim has Claim Number,
|
|
19
|
+
ClaimDetailsClaimNumber Int NOT NULL,
|
|
20
|
+
-- Claim Payment is for Claim Details and Claim Details involves Date,
|
|
21
|
+
ClaimDetailsDate datetime NOT NULL,
|
|
22
|
+
-- Claim Payment is for Claim Details and Claim Details involves Policy Coverage and Policy Coverage involves Policy and Policy is from Insurer and Insurer has Insurer Name,
|
|
23
|
+
ClaimDetailsPolicyCoveragePolicyInsurerName varchar NOT NULL,
|
|
24
|
+
-- Claim Payment is for Claim Details and Claim Details involves Policy Coverage and Policy Coverage involves Policy and Policy has Policy Number,
|
|
25
|
+
ClaimDetailsPolicyCoveragePolicyNumber Int NOT NULL,
|
|
26
|
+
-- Claim Payment is for Claim Details and Claim Details involves Policy Coverage and Policy Coverage involves Coverage Type and Coverage Type has Coverage Type Name,
|
|
27
|
+
ClaimDetailsPolicyCoverageTypeName varchar NOT NULL,
|
|
28
|
+
-- Claim Payment is of Claim Payment Type and Claim Payment Type has Claim Payment Type Code,
|
|
29
|
+
ClaimPaymentTypeCode varchar(16) NOT NULL,
|
|
30
|
+
PRIMARY KEY(ClaimDetailsClaimNumber, ClaimDetailsPolicyCoveragePolicyInsurerName, ClaimDetailsPolicyCoveragePolicyNumber, ClaimDetailsPolicyCoverageTypeName, ClaimDetailsDate),
|
|
31
|
+
FOREIGN KEY (ClaimDetailsClaimNumber) REFERENCES Claim (ClaimNumber)
|
|
32
|
+
)
|
|
33
|
+
GO
|
|
34
|
+
|
|
35
|
+
CREATE TABLE ClaimPaymentType (
|
|
36
|
+
-- Claim Payment Type has Claim Payment Type Code,
|
|
37
|
+
ClaimPaymentTypeCode varchar(16) NOT NULL,
|
|
38
|
+
-- maybe Claim Payment Type has descriptive-Text,
|
|
39
|
+
DescriptiveText varchar NULL,
|
|
40
|
+
PRIMARY KEY(ClaimPaymentTypeCode)
|
|
41
|
+
)
|
|
42
|
+
GO
|
|
43
|
+
|
|
44
|
+
CREATE TABLE CoverageType (
|
|
45
|
+
-- Coverage Type has Coverage Type Name,
|
|
46
|
+
CoverageTypeName varchar NOT NULL,
|
|
47
|
+
-- maybe Coverage Type has descriptive-Text,
|
|
48
|
+
DescriptiveText varchar NULL,
|
|
49
|
+
PRIMARY KEY(CoverageTypeName)
|
|
50
|
+
)
|
|
51
|
+
GO
|
|
52
|
+
|
|
53
|
+
CREATE TABLE Incident (
|
|
54
|
+
-- maybe Incident resulted in Claim and Claim has Claim Number,
|
|
55
|
+
ClaimNumber Int NULL,
|
|
56
|
+
-- Incident affected Claimant and Claimant is a kind of Stakeholder and Stakeholder is a kind of Party and Party has Party ID,
|
|
57
|
+
ClaimantID int NOT NULL,
|
|
58
|
+
-- Incident occurred on Date,
|
|
59
|
+
Date datetime NOT NULL,
|
|
60
|
+
-- maybe Incident has descriptive-Text,
|
|
61
|
+
DescriptiveText varchar NULL,
|
|
62
|
+
-- Incident has Incident ID,
|
|
63
|
+
IncidentID int IDENTITY NOT NULL,
|
|
64
|
+
-- Incident is of Incident Type and Incident Type has Incident Type Name,
|
|
65
|
+
IncidentTypeName varchar NOT NULL,
|
|
66
|
+
PRIMARY KEY(IncidentID),
|
|
67
|
+
FOREIGN KEY (ClaimNumber) REFERENCES Claim (ClaimNumber)
|
|
68
|
+
)
|
|
69
|
+
GO
|
|
70
|
+
|
|
71
|
+
CREATE VIEW dbo.Incident_ClaimNumber (ClaimNumber) WITH SCHEMABINDING AS
|
|
72
|
+
SELECT ClaimNumber FROM dbo.Incident
|
|
73
|
+
WHERE ClaimNumber IS NOT NULL
|
|
74
|
+
GO
|
|
75
|
+
|
|
76
|
+
CREATE UNIQUE CLUSTERED INDEX IX_IncidentByClaimNumber ON dbo.Incident_ClaimNumber(ClaimNumber)
|
|
77
|
+
GO
|
|
78
|
+
|
|
79
|
+
CREATE TABLE IncidentType (
|
|
80
|
+
-- Incident Type has Incident Type Name,
|
|
81
|
+
IncidentTypeName varchar NOT NULL,
|
|
82
|
+
PRIMARY KEY(IncidentTypeName)
|
|
83
|
+
)
|
|
84
|
+
GO
|
|
85
|
+
|
|
86
|
+
CREATE TABLE Insurer (
|
|
87
|
+
-- Insurer has Insurer Name,
|
|
88
|
+
InsurerName varchar NOT NULL,
|
|
89
|
+
PRIMARY KEY(InsurerName)
|
|
90
|
+
)
|
|
91
|
+
GO
|
|
92
|
+
|
|
93
|
+
CREATE TABLE Party (
|
|
94
|
+
-- Party has Party ID,
|
|
95
|
+
PartyID int IDENTITY NOT NULL,
|
|
96
|
+
PRIMARY KEY(PartyID)
|
|
97
|
+
)
|
|
98
|
+
GO
|
|
99
|
+
|
|
100
|
+
CREATE TABLE Policy (
|
|
101
|
+
-- Policy was purchased on Date,
|
|
102
|
+
Date datetime NOT NULL,
|
|
103
|
+
-- Policy is from Insurer and Insurer has Insurer Name,
|
|
104
|
+
InsurerName varchar NOT NULL,
|
|
105
|
+
-- Policy is held by Policy Holder and Policy Holder is a kind of Stakeholder and Stakeholder is a kind of Party and Party has Party ID,
|
|
106
|
+
PolicyHolderID int NOT NULL,
|
|
107
|
+
-- Policy has Policy Number,
|
|
108
|
+
PolicyNumber Int NOT NULL,
|
|
109
|
+
-- Policy was purchased from Product Offering and Product Offering has Product Offering Name,
|
|
110
|
+
ProductOfferingName varchar NOT NULL,
|
|
111
|
+
PRIMARY KEY(InsurerName, PolicyNumber),
|
|
112
|
+
FOREIGN KEY (InsurerName) REFERENCES Insurer (InsurerName),
|
|
113
|
+
FOREIGN KEY (PolicyHolderID) REFERENCES Party (PartyID)
|
|
114
|
+
)
|
|
115
|
+
GO
|
|
116
|
+
|
|
117
|
+
CREATE TABLE PolicyCoverage (
|
|
118
|
+
-- maybe Policy Coverage is at Coverage Level,
|
|
119
|
+
CoverageLevel Int NULL,
|
|
120
|
+
-- Policy Coverage involves Coverage Type and Coverage Type has Coverage Type Name,
|
|
121
|
+
CoverageTypeName varchar NOT NULL,
|
|
122
|
+
-- Policy Coverage involves Policy and Policy is from Insurer and Insurer has Insurer Name,
|
|
123
|
+
PolicyInsurerName varchar NOT NULL,
|
|
124
|
+
-- Policy Coverage involves Policy and Policy has Policy Number,
|
|
125
|
+
PolicyNumber Int NOT NULL,
|
|
126
|
+
PRIMARY KEY(PolicyInsurerName, PolicyNumber, CoverageTypeName),
|
|
127
|
+
FOREIGN KEY (CoverageTypeName) REFERENCES CoverageType (CoverageTypeName),
|
|
128
|
+
FOREIGN KEY (PolicyInsurerName, PolicyNumber) REFERENCES Policy (InsurerName, PolicyNumber)
|
|
129
|
+
)
|
|
130
|
+
GO
|
|
131
|
+
|
|
132
|
+
CREATE TABLE ProductOffering (
|
|
133
|
+
-- Product Offering is offered by Insurer and Insurer has Insurer Name,
|
|
134
|
+
InsurerName varchar NOT NULL,
|
|
135
|
+
-- Product Offering has Product Offering Name,
|
|
136
|
+
ProductOfferingName varchar NOT NULL,
|
|
137
|
+
PRIMARY KEY(ProductOfferingName),
|
|
138
|
+
FOREIGN KEY (InsurerName) REFERENCES Insurer (InsurerName)
|
|
139
|
+
)
|
|
140
|
+
GO
|
|
141
|
+
|
|
142
|
+
ALTER TABLE AvailableCoverage
|
|
143
|
+
ADD FOREIGN KEY (CoverageTypeName) REFERENCES CoverageType (CoverageTypeName)
|
|
144
|
+
GO
|
|
145
|
+
|
|
146
|
+
ALTER TABLE AvailableCoverage
|
|
147
|
+
ADD FOREIGN KEY (ProductOfferingName) REFERENCES ProductOffering (ProductOfferingName)
|
|
148
|
+
GO
|
|
149
|
+
|
|
150
|
+
ALTER TABLE ClaimPayment
|
|
151
|
+
ADD FOREIGN KEY (ClaimPaymentTypeCode) REFERENCES ClaimPaymentType (ClaimPaymentTypeCode)
|
|
152
|
+
GO
|
|
153
|
+
|
|
154
|
+
ALTER TABLE ClaimPayment
|
|
155
|
+
ADD FOREIGN KEY (ClaimDetailsPolicyCoveragePolicyInsurerName, ClaimDetailsPolicyCoveragePolicyNumber, ClaimDetailsPolicyCoverageTypeName) REFERENCES PolicyCoverage (PolicyInsurerName, PolicyNumber, CoverageTypeName)
|
|
156
|
+
GO
|
|
157
|
+
|
|
158
|
+
ALTER TABLE Incident
|
|
159
|
+
ADD FOREIGN KEY (IncidentTypeName) REFERENCES IncidentType (IncidentTypeName)
|
|
160
|
+
GO
|
|
161
|
+
|
|
162
|
+
ALTER TABLE Incident
|
|
163
|
+
ADD FOREIGN KEY (ClaimantID) REFERENCES Party (PartyID)
|
|
164
|
+
GO
|
|
165
|
+
|
|
166
|
+
ALTER TABLE Policy
|
|
167
|
+
ADD FOREIGN KEY (ProductOfferingName) REFERENCES ProductOffering (ProductOfferingName)
|
|
168
|
+
GO
|
|
169
|
+
|