activefacts-examples 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/ruby/WaiterTips.rb
ADDED
@@ -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
|
data/ruby/Warehousing.rb
ADDED
@@ -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
|
+
|
data/sql/server/Blog.sql
ADDED
@@ -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
|
+
|