-
Notifications
You must be signed in to change notification settings - Fork 0
/
initialize.ddl
1386 lines (961 loc) · 35.9 KB
/
initialize.ddl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- ������Oracle SQL Developer Data Modeler 22.2.0.165.1149
-- ʱ��: 2023-04-08 13:26:17 EDT
-- վ��: SQL Server 2012
-- ����: SQL Server 2012
CREATE TABLE AFZ_Activity
(
Activity_ID NUMERIC (10) NOT NULL IDENTITY NOT FOR REPLICATION ,
Amount_Due NUMERIC (10,2) ,
Facility_ID NUMERIC (5) ,
Source_Type VARCHAR (3) NOT NULL ,
Visitor_ID NUMERIC (6) NOT NULL ,
Activity_Date DATETIME NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the activity' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Activity' , 'COLUMN' , 'Activity_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The total amount due to the Activity.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Activity' , 'COLUMN' , 'Amount_Due'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The ID of the facility of Activity
' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Activity' , 'COLUMN' , 'Facility_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The type of the facility of the Activity.
' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Activity' , 'COLUMN' , 'Source_Type'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Visitor in the acitivity
' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Activity' , 'COLUMN' , 'Visitor_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Date that the activity happens.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Activity' , 'COLUMN' , 'Activity_Date'
GO
ALTER TABLE AFZ_Activity ADD CONSTRAINT AFZ_Activity_PK PRIMARY KEY CLUSTERED (Activity_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Attraction_Status
(
Status_Type_ID NUMERIC (1) NOT NULL IDENTITY NOT FOR REPLICATION ,
Status_Type VARCHAR (32) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Unique status type.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Attraction_Status' , 'COLUMN' , 'Status_Type_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Status Type: open, closed, under maintenance' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Attraction_Status' , 'COLUMN' , 'Status_Type'
GO
ALTER TABLE AFZ_Attraction_Status ADD CONSTRAINT AFZ_Attraction_Status_PK PRIMARY KEY CLUSTERED (Status_Type_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Attraction_Type
(
Attraction_Type_ID NUMERIC (2) NOT NULL IDENTITY NOT FOR REPLICATION ,
Attraction_Type VARCHAR (32) NOT NULL ,
Description VARCHAR (255) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Unique attraction type.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Attraction_Type' , 'COLUMN' , 'Attraction_Type_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Attraction type:roller coaster, water ride, dark ride, kid ride etc' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Attraction_Type' , 'COLUMN' , 'Attraction_Type'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The description of the Type of Attraction.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Attraction_Type' , 'COLUMN' , 'Description'
GO
ALTER TABLE AFZ_Attraction_Type ADD CONSTRAINT AFZ_Attraction_Type_PK PRIMARY KEY CLUSTERED (Attraction_Type_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Attractions
(
Facility_ID NUMERIC (5) NOT NULL ,
Minimum_Height NUMERIC (3) NOT NULL ,
Durations NUMERIC (3) NOT NULL ,
Attraction_Type_ID NUMERIC (2) NOT NULL ,
Status_Type_ID NUMERIC (1) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the facility. The primary key' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Attractions' , 'COLUMN' , 'Facility_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The minimum height required to enter the attraction. (Unit: inch)' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Attractions' , 'COLUMN' , 'Minimum_Height'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The durations of the attraction.(Unit: second)' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Attractions' , 'COLUMN' , 'Durations'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The type of the attraction' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Attractions' , 'COLUMN' , 'Attraction_Type_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The status of the attraction' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Attractions' , 'COLUMN' , 'Status_Type_ID'
GO
ALTER TABLE AFZ_Attractions ADD CONSTRAINT AFZ_Attractions_PK PRIMARY KEY CLUSTERED (Facility_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Card_Payment
(
Payment_ID NUMERIC (10) NOT NULL ,
Card_Number NUMERIC (16) NOT NULL ,
Holder_FName VARCHAR (20) NOT NULL ,
Holder_LName VARCHAR (20) NOT NULL ,
CVV NUMERIC (3) NOT NULL ,
Expiration_Date DATE NOT NULL ,
Card_Type VARCHAR (6) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The payment of the visitor pay for each source.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Card_Payment' , 'COLUMN' , 'Payment_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Card number of the payment' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Card_Payment' , 'COLUMN' , 'Card_Number'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'First name of the card holder.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Card_Payment' , 'COLUMN' , 'Holder_FName'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Last name of the card holder.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Card_Payment' , 'COLUMN' , 'Holder_LName'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The CVV number of the card' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Card_Payment' , 'COLUMN' , 'CVV'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Expiration date of the card' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Card_Payment' , 'COLUMN' , 'Expiration_Date'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The type of the card, to determine whether it is credit or debit.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Card_Payment' , 'COLUMN' , 'Card_Type'
GO
ALTER TABLE AFZ_Card_Payment ADD CONSTRAINT AFZ_Card_Payment_PK PRIMARY KEY CLUSTERED (Payment_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Facility
(
Facility_ID NUMERIC (5) NOT NULL IDENTITY NOT FOR REPLICATION ,
Source_Type VARCHAR (3) NOT NULL ,
Facility_URL VARCHAR (255) NOT NULL ,
Facility_Description VARCHAR (255) NOT NULL ,
Facility_Name VARCHAR (100) NOT NULL ,
Location_Section_ID VARCHAR (2) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the facility. The primary key' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Facility' , 'COLUMN' , 'Facility_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Type of the Facility.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Facility' , 'COLUMN' , 'Source_Type'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The URL of the image of the Facility.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Facility' , 'COLUMN' , 'Facility_URL'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'the Description of the Facility.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Facility' , 'COLUMN' , 'Facility_Description'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Name of the Facility.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Facility' , 'COLUMN' , 'Facility_Name'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The id of the Facfility location' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Facility' , 'COLUMN' , 'Location_Section_ID'
GO
ALTER TABLE AFZ_Facility ADD CONSTRAINT AFZ_Facility_PK PRIMARY KEY CLUSTERED (Facility_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Holidays
(
Holiday_Date DATETIME NOT NULL ,
Holiday_Name VARCHAR (50) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The date of the holiday.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Holidays' , 'COLUMN' , 'Holiday_Date'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The holiday name.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Holidays' , 'COLUMN' , 'Holiday_Name'
GO
ALTER TABLE AFZ_Holidays ADD CONSTRAINT AFZ_Holidays_PK PRIMARY KEY CLUSTERED (Holiday_Date)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Item
(
Item_ID NUMERIC (5) NOT NULL IDENTITY NOT FOR REPLICATION ,
Item_Name VARCHAR (20) NOT NULL ,
Item_Des VARCHAR (128) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the item. Primary Key of this table.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Item' , 'COLUMN' , 'Item_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Name of this Item' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Item' , 'COLUMN' , 'Item_Name'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Description of the Item.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Item' , 'COLUMN' , 'Item_Des'
GO
ALTER TABLE AFZ_Item ADD CONSTRAINT AFZ_Item_PK PRIMARY KEY CLUSTERED (Item_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Item_Store
(
Item_ID NUMERIC (5) NOT NULL ,
Facility_ID NUMERIC (5) NOT NULL ,
Unit_Price NUMERIC (5,2) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'UID of the item.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Item_Store' , 'COLUMN' , 'Item_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of store' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Item_Store' , 'COLUMN' , 'Facility_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The unit price of the item in the store' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Item_Store' , 'COLUMN' , 'Unit_Price'
GO
ALTER TABLE AFZ_Item_Store ADD CONSTRAINT AFZ_Item_Store_PK PRIMARY KEY CLUSTERED (Item_ID, Facility_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Locations
(
Location_Section_ID VARCHAR (2) NOT NULL ,
Location_Description VARCHAR (255) NOT NULL ,
Location_URL VARCHAR (255) NOT NULL ,
Location_Name VARCHAR (50) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Unique location section id.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Locations' , 'COLUMN' , 'Location_Section_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Description of the Location Section.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Locations' , 'COLUMN' , 'Location_Description'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The URL of the image of this Section.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Locations' , 'COLUMN' , 'Location_URL'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Name of the section.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Locations' , 'COLUMN' , 'Location_Name'
GO
ALTER TABLE AFZ_Locations ADD CONSTRAINT AFZ_Locations_PK PRIMARY KEY CLUSTERED (Location_Section_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Order
(
Order_ID NUMERIC (5) NOT NULL IDENTITY NOT FOR REPLICATION ,
Activity_ID NUMERIC (10) NOT NULL ,
Quantity NUMERIC (5) NOT NULL ,
Order_Date DATETIME NOT NULL ,
Item_ID NUMERIC (5) NOT NULL ,
Store_Facility_ID NUMERIC (5) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The primary key of this table.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Order' , 'COLUMN' , 'Order_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The ID of the activity' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Order' , 'COLUMN' , 'Activity_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Item quantity in order. ' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Order' , 'COLUMN' , 'Quantity'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The date of the order
' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Order' , 'COLUMN' , 'Order_Date'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Item ID in this order.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Order' , 'COLUMN' , 'Item_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Facility ID of this order' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Order' , 'COLUMN' , 'Store_Facility_ID'
GO
ALTER TABLE AFZ_Order ADD CONSTRAINT AFZ_Order_PK PRIMARY KEY CLUSTERED (Order_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Parking
(
Activity_ID NUMERIC (10) NOT NULL ,
Time_In DATETIME NOT NULL ,
Time_Out DATETIME NOT NULL ,
Spot_Number NUMERIC (3) NOT NULL ,
Parking_Section_ID NUMERIC (2) NOT NULL ,
Fee NUMERIC (5,2) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the activity' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Parking' , 'COLUMN' , 'Activity_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The time the visitor starts parking' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Parking' , 'COLUMN' , 'Time_In'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The time the visitor ends parking' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Parking' , 'COLUMN' , 'Time_Out'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Spot Number of the parking lot.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Parking' , 'COLUMN' , 'Spot_Number'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Section of this spot.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Parking' , 'COLUMN' , 'Parking_Section_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The paring fee.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Parking' , 'COLUMN' , 'Fee'
GO
ALTER TABLE AFZ_Parking ADD CONSTRAINT AFZ_Parking_PK PRIMARY KEY CLUSTERED (Activity_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Parking_Sections
(
Parking_Section_ID NUMERIC (2) NOT NULL IDENTITY NOT FOR REPLICATION ,
Parking_Section VARCHAR (1) NOT NULL ,
Description VARCHAR (255) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Unique location section id.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Parking_Sections' , 'COLUMN' , 'Parking_Section_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Location Section UID' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Parking_Sections' , 'COLUMN' , 'Parking_Section'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The description of this parking section' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Parking_Sections' , 'COLUMN' , 'Description'
GO
ALTER TABLE AFZ_Parking_Sections ADD CONSTRAINT AFZ_Parking_Locations_PK PRIMARY KEY CLUSTERED (Parking_Section_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Payment
(
Payment_ID NUMERIC (10) NOT NULL IDENTITY NOT FOR REPLICATION ,
Payment_Amount NUMERIC (8,2) NOT NULL ,
Payment_Date DATETIME NOT NULL ,
Payment_Method VARCHAR (4) NOT NULL ,
Facility_ID NUMERIC (5) ,
Activity_ID NUMERIC (10) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The payment of the visitor pay for each source.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Payment' , 'COLUMN' , 'Payment_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Payment amount.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Payment' , 'COLUMN' , 'Payment_Amount'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Payment date.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Payment' , 'COLUMN' , 'Payment_Date'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The code of payment method.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Payment' , 'COLUMN' , 'Payment_Method'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The ID of the facility.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Payment' , 'COLUMN' , 'Facility_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The ID of the activity' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Payment' , 'COLUMN' , 'Activity_ID'
GO
ALTER TABLE AFZ_Payment ADD CONSTRAINT AFZ_Payment_PK PRIMARY KEY CLUSTERED (Payment_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Show_Schedule
(
SS_ID NUMERIC (5) NOT NULL IDENTITY NOT FOR REPLICATION ,
Start_Time DATETIME NOT NULL ,
End_Time DATETIME NOT NULL ,
Show_Facility_ID NUMERIC (5) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The ID of the Show Schedule' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Show_Schedule' , 'COLUMN' , 'SS_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Start time of the show.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Show_Schedule' , 'COLUMN' , 'Start_Time'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'End Time of the show.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Show_Schedule' , 'COLUMN' , 'End_Time'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The ID of the show.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Show_Schedule' , 'COLUMN' , 'Show_Facility_ID'
GO
ALTER TABLE AFZ_Show_Schedule ADD CONSTRAINT AFZ_Show_Schedule_PK PRIMARY KEY CLUSTERED (SS_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Show_Type
(
Show_Type_ID NUMERIC (2) NOT NULL IDENTITY NOT FOR REPLICATION ,
Show_Type VARCHAR (16) NOT NULL ,
Description VARCHAR (255) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Unique show type id.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Show_Type' , 'COLUMN' , 'Show_Type_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Show type: drama, musical, comedy, horror, adventure' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Show_Type' , 'COLUMN' , 'Show_Type'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The description of the Type of Show.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Show_Type' , 'COLUMN' , 'Description'
GO
ALTER TABLE AFZ_Show_Type ADD CONSTRAINT AFZ_Show_Type_PK PRIMARY KEY CLUSTERED (Show_Type_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Show_Watch
(
Activity_ID NUMERIC (10) NOT NULL ,
Watch_Time DATETIME NOT NULL ,
SS_ID NUMERIC (5) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the activity' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Show_Watch' , 'COLUMN' , 'Activity_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The time the visitor watchs the show.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Show_Watch' , 'COLUMN' , 'Watch_Time'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The ID of the Show Schedule' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Show_Watch' , 'COLUMN' , 'SS_ID'
GO
ALTER TABLE AFZ_Show_Watch ADD CONSTRAINT AFZ_Show_Watch_PK PRIMARY KEY CLUSTERED (Activity_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Shows
(
Facility_ID NUMERIC (5) NOT NULL ,
Accessibility NUMERIC (1) NOT NULL ,
Price NUMERIC (8,2) NOT NULL ,
Show_Type_ID NUMERIC (2) NOT NULL ,
Duration NUMERIC (4) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the facility. The primary key' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Shows' , 'COLUMN' , 'Facility_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Wheelchair accessibility:Yes or No' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Shows' , 'COLUMN' , 'Accessibility'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The price of the show.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Shows' , 'COLUMN' , 'Price'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the Show' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Shows' , 'COLUMN' , 'Show_Type_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The length of the show. (in minutes)' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Shows' , 'COLUMN' , 'Duration'
GO
ALTER TABLE AFZ_Shows ADD CONSTRAINT AFZ_Shows_PK PRIMARY KEY CLUSTERED (Facility_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Source_Type
(
Source_Type VARCHAR (3) NOT NULL ,
Source_Type_Name VARCHAR (20) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Code of the source Type.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Source_Type' , 'COLUMN' , 'Source_Type'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The full name of the Type of the Facility.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Source_Type' , 'COLUMN' , 'Source_Type_Name'
GO
ALTER TABLE AFZ_Source_Type ADD CONSTRAINT AFZ_Source_Type_PK PRIMARY KEY CLUSTERED (Source_Type)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Store
(
Facility_ID NUMERIC (5) NOT NULL ,
Category_ID NUMERIC (2) NOT NULL ,
Open_Time TIME NOT NULL ,
Close_Time TIME NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the facility. The primary key' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Store' , 'COLUMN' , 'Facility_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Category Store ID.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Store' , 'COLUMN' , 'Category_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The open time of the store.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Store' , 'COLUMN' , 'Open_Time'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The close time of the Store.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Store' , 'COLUMN' , 'Close_Time'
GO
ALTER TABLE AFZ_Store ADD CONSTRAINT AFZ_Store_PK PRIMARY KEY CLUSTERED (Facility_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Store_Category
(
Category_ID NUMERIC (2) NOT NULL IDENTITY NOT FOR REPLICATION ,
Category VARCHAR (32) NOT NULL ,
Description VARCHAR (255) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Unique Category Store ID.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Store_Category' , 'COLUMN' , 'Category_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Store Category:
Food stall, Ice cream parlor, Restaurant, Gift Shop, Apparels' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Store_Category' , 'COLUMN' , 'Category'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The description of the Type of store.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Store_Category' , 'COLUMN' , 'Description'
GO
ALTER TABLE AFZ_Store_Category ADD CONSTRAINT AFZ_Store_Category_PK PRIMARY KEY CLUSTERED (Category_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Ticket_Method
(
Method_Type_ID NUMERIC (1) NOT NULL IDENTITY NOT FOR REPLICATION ,
Method_Type VARCHAR (8) NOT NULL ,
Discount NUMERIC (3,2) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Unique method ID.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Ticket_Method' , 'COLUMN' , 'Method_Type_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Ticket method: Online, Onsite.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Ticket_Method' , 'COLUMN' , 'Method_Type'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Discount of this method.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Ticket_Method' , 'COLUMN' , 'Discount'
GO
ALTER TABLE AFZ_Ticket_Method ADD CONSTRAINT AFZ_Ticket_Method_PK PRIMARY KEY CLUSTERED (Method_Type_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Ticket_Type
(
Ticket_Type_ID NUMERIC (1) NOT NULL IDENTITY NOT FOR REPLICATION ,
Ticket_Type VARCHAR (32) NOT NULL ,
Discount NUMERIC (3,2) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Unique ticket type.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Ticket_Type' , 'COLUMN' , 'Ticket_Type_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Ticket type: Child, Adult, Senior, or Member' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Ticket_Type' , 'COLUMN' , 'Ticket_Type'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Discount of this method.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Ticket_Type' , 'COLUMN' , 'Discount'
GO
ALTER TABLE AFZ_Ticket_Type ADD CONSTRAINT AFZ_Ticket_Type_PK PRIMARY KEY CLUSTERED (Ticket_Type_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Tickets
(
Ticket_ID NUMERIC (10) NOT NULL IDENTITY NOT FOR REPLICATION ,
Method_Type_ID NUMERIC (1) NOT NULL ,
Ticket_Type_ID NUMERIC (1) NOT NULL ,
Purchase_Date DATETIME NOT NULL ,
Visit_Date DATETIME NOT NULL ,
Validate AS case when CAST(visit_date as DATE) = CAST(getutcdate() as DATE) then 1 else 0 end ,
Price NUMERIC (10,2) NOT NULL ,
Activity_ID NUMERIC (10) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the Ticket' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Tickets' , 'COLUMN' , 'Ticket_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the ticket purchase method' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Tickets' , 'COLUMN' , 'Method_Type_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The UID of the Ticket type' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Tickets' , 'COLUMN' , 'Ticket_Type_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Purchase date of the ticket.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Tickets' , 'COLUMN' , 'Purchase_Date'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Visit date of the ticket.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Tickets' , 'COLUMN' , 'Visit_Date'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'This is a computed column. Only be 1 while the system date is same to the visit date.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Tickets' , 'COLUMN' , 'Validate'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The Price of this type of ticket.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Tickets' , 'COLUMN' , 'Price'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The ID of the purchase activity
' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Tickets' , 'COLUMN' , 'Activity_ID'
GO
ALTER TABLE AFZ_Tickets ADD CONSTRAINT AFZ_Tickets_PK PRIMARY KEY CLUSTERED (Ticket_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Visitor_Type
(
Visitor_Type_ID NUMERIC (1) NOT NULL IDENTITY NOT FOR REPLICATION ,
Visitor_Type VARCHAR (32) NOT NULL
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Unique visitor type id.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Visitor_Type' , 'COLUMN' , 'Visitor_Type_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Vistor type: Individual, Group, Member or Student' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Visitor_Type' , 'COLUMN' , 'Visitor_Type'
GO
ALTER TABLE AFZ_Visitor_Type ADD CONSTRAINT AFZ_Visitor_Type_PK PRIMARY KEY CLUSTERED (Visitor_Type_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
CREATE TABLE AFZ_Visitors
(
Visitor_ID NUMERIC (6) NOT NULL IDENTITY NOT FOR REPLICATION ,
Fname VARCHAR (32) NOT NULL ,
Lname VARCHAR (32) NOT NULL ,
City VARCHAR (32) NOT NULL ,
Email VARCHAR (32) NOT NULL ,
Cell_Number VARCHAR (10) NOT NULL ,
Birthdate DATE NOT NULL ,
Visitor_Type_ID NUMERIC (1) NOT NULL DEFAULT 2 ,
Password VARCHAR (255)
)
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Unique Visitor ID.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Visitors' , 'COLUMN' , 'Visitor_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'First name of visitor' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Visitors' , 'COLUMN' , 'Fname'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'Last name of visitor' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Visitors' , 'COLUMN' , 'Lname'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The city of visitor.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Visitors' , 'COLUMN' , 'City'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The email of visitor' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Visitors' , 'COLUMN' , 'Email'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The cell phone number of visitor.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Visitors' , 'COLUMN' , 'Cell_Number'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The birthdate of the visitor.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Visitors' , 'COLUMN' , 'Birthdate'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The type of the visitor.
' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Visitors' , 'COLUMN' , 'Visitor_Type_ID'
GO
EXEC sp_addextendedproperty 'MS_Description' , 'The password of the user.' , 'USER' , 'dbo' , 'TABLE' , 'AFZ_Visitors' , 'COLUMN' , 'Password'
GO
ALTER TABLE AFZ_Visitors ADD CONSTRAINT AFZ_Visitors_PK PRIMARY KEY CLUSTERED (Visitor_ID)
WITH (
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON )
GO
ALTER TABLE AFZ_Activity
ADD CONSTRAINT Activity_Facility_FK FOREIGN KEY
(
Facility_ID
)
REFERENCES AFZ_Facility
(
Facility_ID
)
ON DELETE NO ACTION
ON UPDATE NO ACTION
GO
ALTER TABLE AFZ_Show_Watch
ADD CONSTRAINT Activity_FK FOREIGN KEY
(
Activity_ID
)
REFERENCES AFZ_Activity
(
Activity_ID
)
ON DELETE NO ACTION
ON UPDATE NO ACTION
GO
ALTER TABLE AFZ_Activity
ADD CONSTRAINT Activity_Source_Type_FK FOREIGN KEY
(
Source_Type
)
REFERENCES AFZ_Source_Type
(
Source_Type
)