-
Notifications
You must be signed in to change notification settings - Fork 2
/
GSC_Building_2.1e_PostGIS.sql
1699 lines (1271 loc) · 87.9 KB
/
GSC_Building_2.1e_PostGIS.sql
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
-- Operazione di generaione del SQL per Postgis
-- Data i creazione dello script:Thu Jul 09 19:16:37 CEST 2015
-- Specifica:GeoSmartCity Building Data Model
-- Specifica identificatore:
-- Specifica numero di versione:2.1
-- Specifica data di creazione:05 maggio 2015 - 15:02:14
-- Specifica data di ultima modifica:09 luglio 2015 - 19:15:00
-- Specifica stato:work in progress ( 01 agosto 2014 - 19:25:00 )
-- Dps nome:Gsc_postgis
-- Dps data di creazione:14 maggio 2015 - 11:22:46
-- Dps Spatial Reference System:EPSG:3044
-- Dps nome del modello implementativo:SQL_ESF_FLAT_MONO
-- Dps versione del modello implementativo:1.0
-- Dps database del modello implementativo:PostGIS
-- Dps implementazione sottoaree B3D:2D
-- Dps implementazione eventi - stratti - sottoaree:non connessi
-- Saranno create:
-- 4 tabelle per le classi
-- 21 tabelle per la trascodifica dei domini
-- 0 tabelle segment event subregion
-- 9 tabelle per i datatype
-- 5 tabelle di supporto ad attributi multivalore
-- 0 tabelle per gli strati topologici
-- 0 tabelle per ruoli e associzioni
-- 0 tabelle per codifica dei valori nulli
-- 0 tabelle per le geometrie esterne e aggregati
-- 0 tabelle per le geometrie collassate
--
-- Generazione tabelle per la trascodifica dei domini
--
--
-- CREATE TABLE: d_occupancytype
-- Rappresenta la tabella di trascodifica del dominio: Occupancy type value - OCCUPANCYTYPE
--
CREATE TABLE d_occupancytype (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_type_value
-- Rappresenta la tabella di trascodifica del dominio: Type value - TYPE_VALUE
--
CREATE TABLE d_type_value (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: h_currentuse
-- Rappresenta la tabella di trascodifica del dominio gerarchico: Current use value - CURRENTUSE
--
CREATE TABLE h_currentuse (
code varchar(80) NOT NULL,
name varchar(850),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: h_energysource
-- Rappresenta la tabella di trascodifica del dominio gerarchico: Energy source value - ENERGYSOURCE
--
CREATE TABLE h_energysource (
code varchar(80) NOT NULL,
name varchar(850),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_clge
-- Rappresenta la tabella di trascodifica del dominio: Clge official area reference value - CLGE
--
CREATE TABLE d_clge (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_rooftype
-- Rappresenta la tabella di trascodifica del dominio: Roof type value - ROOFTYPE
--
CREATE TABLE d_rooftype (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_elevationreference
-- Rappresenta la tabella di trascodifica del dominio: Elevation reference - ELEVATIONREFERENCE
--
CREATE TABLE d_elevationreference (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_perf_class
-- Rappresenta la tabella di trascodifica del dominio: Energy performance class - PERF_CLASS
--
CREATE TABLE d_perf_class (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_buildingnature
-- Rappresenta la tabella di trascodifica del dominio: Building nature value - BUILDINGNATURE
--
CREATE TABLE d_buildingnature (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_conditionofconstruction
-- Rappresenta la tabella di trascodifica del dominio: Condition of construction value - CONDITIONOFCONSTRUCTION
--
CREATE TABLE d_conditionofconstruction (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: h_uom
-- Rappresenta la tabella di trascodifica del dominio gerarchico: Unit of measure - UOM
--
CREATE TABLE h_uom (
code varchar(80) NOT NULL,
name varchar(850),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_installationnature
-- Rappresenta la tabella di trascodifica del dominio: Installation nature value - INSTALLATIONNATURE
--
CREATE TABLE d_installationnature (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: h_ownershiptype
-- Rappresenta la tabella di trascodifica del dominio gerarchico: Ownership type value - OWNERSHIPTYPE
--
CREATE TABLE h_ownershiptype (
code varchar(80) NOT NULL,
name varchar(850),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_energyuse
-- Rappresenta la tabella di trascodifica del dominio: Energy use value - ENERGYUSE
--
CREATE TABLE d_energyuse (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: h_location
-- Rappresenta la tabella di trascodifica del dominio gerarchico: Location - LOCATION
--
CREATE TABLE h_location (
code varchar(80) NOT NULL,
name varchar(850),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_buildingtype
-- Rappresenta la tabella di trascodifica del dominio: Building type - BUILDINGTYPE
--
CREATE TABLE d_buildingtype (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_material
-- Rappresenta la tabella di trascodifica del dominio: Material value - MATERIAL
--
CREATE TABLE d_material (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_refurbishmentlevel
-- Rappresenta la tabella di trascodifica del dominio: Refurbishment level - REFURBISHMENTLEVEL
--
CREATE TABLE d_refurbishmentlevel (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_energytype
-- Rappresenta la tabella di trascodifica del dominio: Energy type value - ENERGYTYPE
--
CREATE TABLE d_energytype (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_heatingsystem
-- Rappresenta la tabella di trascodifica del dominio: Heating system value - HEATINGSYSTEM
--
CREATE TABLE d_heatingsystem (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- CREATE TABLE: d_heightstatus
-- Rappresenta la tabella di trascodifica del dominio: Height status value - HEIGHTSTATUS
--
CREATE TABLE d_heightstatus (
code varchar(80) NOT NULL,
name varchar(160),
definition varchar(1200),
alphacode varchar(80)
);
--
-- Generazione tabelle per le classi
--
--
-- CREATE TABLE: installation
-- Rappresenta la classe: Installation - INSTALLATION
--
CREATE TABLE installation (
classid varchar(70) NOT NULL,
condition varchar(80) NOT NULL,
date_activation date ,
date_c_beginning numeric(15,0) ,
date_c_end numeric(15,0) ,
date_r_beginning numeric(15,0) ,
date_r_end numeric(15,0) ,
elev_ref varchar(80),
energy_estimated double precision ,
energy_produced double precision ,
height_height_low varchar(80),
height_height_ref varchar(80) NOT NULL,
height_height_stat varchar(80) NOT NULL,
height_height_val double precision ,
identifier_id_loc varchar(40),
identifier_id_name varchar(40),
identifier_id_vers varchar(40),
installation_nature varchar(80) NOT NULL,
lifespan_beginning numeric(15,0) ,
lifespan_end numeric(15,0) ,
name varchar(100),
ownership varchar(80),
power double precision ,
purpose varchar(40),
surface double precision ,
type varchar(80)
);
select addgeometrycolumn ('', 'installation', 'geometry2d', '3044', 'POINT', 2);
--
-- CREATE TABLE: thermalzone
-- Rappresenta la classe: Thermal zone (building part) - THERMALZONE
--
CREATE TABLE thermalzone (
classid varchar(70) NOT NULL,
energyperformance_perf_class varchar(80),
energyperformance_perf_date date ,
energyperformance_perf_method varchar(100),
energyperformance_perf_uom varchar(80),
energyperformance_perf_value numeric(15,0) ,
occupants_occ_value numeric(15,0) ,
occupants_occ_type varchar(80),
volume_source varchar(40),
volume_value double precision ,
tz2bdg varchar(70) NOT NULL
);
--
-- CREATE TABLE: conversion
-- Rappresenta la classe: Conversion class - CONVERSION
--
CREATE TABLE conversion (
classid varchar(70) NOT NULL,
input varchar(80) NOT NULL,
location varchar(80),
output varchar(80) NOT NULL,
value double precision NOT NULL,
year date
);
--
-- CREATE TABLE: buildings
-- Rappresenta la classe: Buildings - BUILDINGS
--
CREATE TABLE buildings (
classid varchar(70) NOT NULL,
buildingtype varchar(80),
condition varchar(80) NOT NULL,
connection_electricity char(1) ,
connection_gas char(1) ,
connection_sewage char(1) ,
connection_thermal char(1) ,
connection_water char(1) ,
date_c_beginning numeric(15,0) ,
date_c_end numeric(15,0) ,
date_r_beginning numeric(15,0) ,
date_r_end numeric(15,0) ,
dist_floor varchar(40) NOT NULL,
elev_ref varchar(80),
floors numeric(15,0) ,
height_height_low varchar(80),
height_height_ref varchar(80) NOT NULL,
height_height_stat varchar(80) NOT NULL,
height_height_val double precision ,
h_floor double precision ,
identifier_id_loc varchar(40),
identifier_id_name varchar(40),
identifier_id_vers varchar(40),
inst_meter char(1) ,
inst_photov char(1) ,
inst_solar char(1) ,
inst_thrplant char(1) ,
lifespan_beginning numeric(15,0) ,
lifespan_end numeric(15,0) ,
name varchar(100),
nature varchar(80),
occupants numeric(15,0) ,
ownership varchar(80),
refurbish varchar(80),
roof_type varchar(80),
units numeric(15,0) ,
use_s varchar(80) NOT NULL,
vert_surf double precision ,
volume_source varchar(40),
volume_value double precision
);
select addgeometrycolumn ('', 'buildings', 'geometry2d', '3044', 'MULTIPOLYGON', 2);
--
-- Generazione tabelle per le geometrie esterne o aggegati
--
--
-- Generazione tabelle per le geometrie collassate
--
--
-- Generazione tabelle per i datatype
--
--
-- CREATE TABLE: thermalzone_energyamount_t
-- Rappresenta il datatype: Energy amount - EnergyAmount
--
CREATE TABLE thermalzone_energyamount_t (
classref varchar(70) NOT NULL,
energyamount_e_amount double precision ,
energyamount_e_source varchar(80) NOT NULL,
energyamount_e_type varchar(80) NOT NULL,
energyamount_e_use varchar(80) NOT NULL,
energyamount_e_year date ,
energyamount_e_uom varchar(80) NOT NULL,
energyamount_estimatedco2 double precision
);
--
-- CREATE TABLE: buildings_energyamount_t
-- Rappresenta il datatype: Energy amount - EnergyAmount
--
CREATE TABLE buildings_energyamount_t (
classref varchar(70) NOT NULL,
energyamount_e_amount double precision ,
energyamount_e_source varchar(80) NOT NULL,
energyamount_e_type varchar(80) NOT NULL,
energyamount_e_use varchar(80) NOT NULL,
energyamount_e_year date ,
energyamount_e_uom varchar(80) NOT NULL,
energyamount_estimatedco2 double precision
);
--
-- CREATE TABLE: installation_ext_ref_t
-- Rappresenta il datatype: External reference - EXT_REF
--
CREATE TABLE installation_ext_ref_t (
classref varchar(70) NOT NULL,
ext_ref_identifier varchar(100),
ext_ref_inf_sys_name varchar(100),
ext_ref_reference varchar(40)
);
--
-- CREATE TABLE: thermalzone_officialarea_t
-- Rappresenta il datatype: Official area - OFF_AREA
--
CREATE TABLE thermalzone_officialarea_t (
classref varchar(70) NOT NULL,
officialarea_area_ref varchar(80) NOT NULL,
officialarea_value double precision
);
--
-- CREATE TABLE: buildings_ext_ref_t
-- Rappresenta il datatype: External reference - EXT_REF
--
CREATE TABLE buildings_ext_ref_t (
classref varchar(70) NOT NULL,
ext_ref_identifier varchar(100),
ext_ref_inf_sys_name varchar(100),
ext_ref_reference varchar(40)
);
--
-- CREATE TABLE: installation_elevation_t
-- Rappresenta il datatype: Elevation - ELEVATION
--
CREATE TABLE installation_elevation_t (
classref varchar(70) NOT NULL,
elevation_elev_val numeric(15,0) ,
elevation_elevationreference varchar(80)
);
--
-- CREATE TABLE: buildings_use_m_t
-- Rappresenta il datatype: Current use - CURR_USE
--
CREATE TABLE buildings_use_m_t (
classref varchar(70) NOT NULL,
use_m_currentuse varchar(80) NOT NULL,
use_m_percentage numeric(15,0)
);
--
-- CREATE TABLE: buildings_elevation_t
-- Rappresenta il datatype: Elevation - ELEVATION
--
CREATE TABLE buildings_elevation_t (
classref varchar(70) NOT NULL,
elevation_elev_val numeric(15,0) ,
elevation_elevationreference varchar(80)
);
--
-- CREATE TABLE: buildings_renewable_potentia_t
-- Rappresenta il datatype: Renewable energy potential - RENEWABLEPOTENTIAL
--
CREATE TABLE buildings_renewable_potentia_t (
classref varchar(70) NOT NULL,
renewable_poten_renewable_sour varchar(80) NOT NULL,
renewable_potential_value double precision
);
--
-- Generazione tabelle di supporto ad attributi multivalore
--
--
-- CREATE TABLE: thermalzone_heatingsystem
-- Rappresenta la tabella di appoggio per l'attributo multivalore: heatingsystem - heatingSystem
--
CREATE TABLE thermalzone_heatingsystem (
classref varchar(70) NOT NULL,
heatingsystem varchar(80) NOT NULL
);
--
-- CREATE TABLE: thermalzone_heatingsource
-- Rappresenta la tabella di appoggio per l'attributo multivalore: heatingsource - heatingSource
--
CREATE TABLE thermalzone_heatingsource (
classref varchar(70) NOT NULL,
heatingsource varchar(80) NOT NULL
);
--
-- CREATE TABLE: buildings_structure_mat
-- Rappresenta la tabella di appoggio per l'attributo multivalore: material of structure - STRUCTURE_MAT
--
CREATE TABLE buildings_structure_mat (
classref varchar(70) NOT NULL,
structure_mat varchar(80) NOT NULL
);
--
-- CREATE TABLE: buildings_facade_mat
-- Rappresenta la tabella di appoggio per l'attributo multivalore: material of facade - FACADE_MAT
--
CREATE TABLE buildings_facade_mat (
classref varchar(70) NOT NULL,
facade_mat varchar(80) NOT NULL
);
--
-- CREATE TABLE: buildings_roof_mat
-- Rappresenta la tabella di appoggio per l'attributo multivalore: material of roof - ROOF_MAT
--
CREATE TABLE buildings_roof_mat (
classref varchar(70) NOT NULL,
roof_mat varchar(80) NOT NULL
);
--
-- Generazione tabelle per la trascodifica dei domini
--
--
-- DOMAIN CONSTRAINT: d_occupancytype
-- PRIMARY KEY per la tabella di trascodifica del dominio : Occupancy type value - OCCUPANCYTYPE
--
ALTER TABLE d_occupancytype ADD CONSTRAINT d_occupancytype_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_type_value
-- PRIMARY KEY per la tabella di trascodifica del dominio : Type value - TYPE_VALUE
--
ALTER TABLE d_type_value ADD CONSTRAINT d_type_value_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: h_currentuse
-- PRIMARY KEY per la tabella di trascodifica del dominio : Current use value - CURRENTUSE
--
ALTER TABLE h_currentuse ADD CONSTRAINT h_currentuse_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: h_energysource
-- PRIMARY KEY per la tabella di trascodifica del dominio : Energy source value - ENERGYSOURCE
--
ALTER TABLE h_energysource ADD CONSTRAINT h_energysource_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_clge
-- PRIMARY KEY per la tabella di trascodifica del dominio : Clge official area reference value - CLGE
--
ALTER TABLE d_clge ADD CONSTRAINT d_clge_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_rooftype
-- PRIMARY KEY per la tabella di trascodifica del dominio : Roof type value - ROOFTYPE
--
ALTER TABLE d_rooftype ADD CONSTRAINT d_rooftype_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_elevationreference
-- PRIMARY KEY per la tabella di trascodifica del dominio : Elevation reference - ELEVATIONREFERENCE
--
ALTER TABLE d_elevationreference ADD CONSTRAINT d_elevationreference_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_perf_class
-- PRIMARY KEY per la tabella di trascodifica del dominio : Energy performance class - PERF_CLASS
--
ALTER TABLE d_perf_class ADD CONSTRAINT d_perf_class_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_buildingnature
-- PRIMARY KEY per la tabella di trascodifica del dominio : Building nature value - BUILDINGNATURE
--
ALTER TABLE d_buildingnature ADD CONSTRAINT d_buildingnature_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_conditionofconstruction
-- PRIMARY KEY per la tabella di trascodifica del dominio : Condition of construction value - CONDITIONOFCONSTRUCTION
--
ALTER TABLE d_conditionofconstruction ADD CONSTRAINT d_conditionofconstruction_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: h_uom
-- PRIMARY KEY per la tabella di trascodifica del dominio : Unit of measure - UOM
--
ALTER TABLE h_uom ADD CONSTRAINT h_uom_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_installationnature
-- PRIMARY KEY per la tabella di trascodifica del dominio : Installation nature value - INSTALLATIONNATURE
--
ALTER TABLE d_installationnature ADD CONSTRAINT d_installationnature_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: h_ownershiptype
-- PRIMARY KEY per la tabella di trascodifica del dominio : Ownership type value - OWNERSHIPTYPE
--
ALTER TABLE h_ownershiptype ADD CONSTRAINT h_ownershiptype_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_energyuse
-- PRIMARY KEY per la tabella di trascodifica del dominio : Energy use value - ENERGYUSE
--
ALTER TABLE d_energyuse ADD CONSTRAINT d_energyuse_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: h_location
-- PRIMARY KEY per la tabella di trascodifica del dominio : Location - LOCATION
--
ALTER TABLE h_location ADD CONSTRAINT h_location_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_buildingtype
-- PRIMARY KEY per la tabella di trascodifica del dominio : Building type - BUILDINGTYPE
--
ALTER TABLE d_buildingtype ADD CONSTRAINT d_buildingtype_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_material
-- PRIMARY KEY per la tabella di trascodifica del dominio : Material value - MATERIAL
--
ALTER TABLE d_material ADD CONSTRAINT d_material_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_refurbishmentlevel
-- PRIMARY KEY per la tabella di trascodifica del dominio : Refurbishment level - REFURBISHMENTLEVEL
--
ALTER TABLE d_refurbishmentlevel ADD CONSTRAINT d_refurbishmentlevel_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_energytype
-- PRIMARY KEY per la tabella di trascodifica del dominio : Energy type value - ENERGYTYPE
--
ALTER TABLE d_energytype ADD CONSTRAINT d_energytype_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_heatingsystem
-- PRIMARY KEY per la tabella di trascodifica del dominio : Heating system value - HEATINGSYSTEM
--
ALTER TABLE d_heatingsystem ADD CONSTRAINT d_heatingsystem_PK PRIMARY KEY (code);
--
-- DOMAIN CONSTRAINT: d_heightstatus
-- PRIMARY KEY per la tabella di trascodifica del dominio : Height status value - HEIGHTSTATUS
--
ALTER TABLE d_heightstatus ADD CONSTRAINT d_heightstatus_PK PRIMARY KEY (code);
--
-- Generazione PK e FK per le classi
--
--
-- TABLE CONSTRAINT: installation
-- PRIMARY KEY per la tabella della classe : Installation - INSTALLATION
--
ALTER TABLE installation ADD CONSTRAINT installation_PK PRIMARY KEY (classid);
--
-- TABLE CONSTRAINT: thermalzone
-- PRIMARY KEY per la tabella della classe : Thermal zone (building part) - THERMALZONE
--
ALTER TABLE thermalzone ADD CONSTRAINT thermalzone_PK PRIMARY KEY (classid);
--
-- TABLE CONSTRAINT: conversion
-- PRIMARY KEY per la tabella della classe : Conversion class - CONVERSION
--
ALTER TABLE conversion ADD CONSTRAINT conversion_PK PRIMARY KEY (classid);
--
-- TABLE CONSTRAINT: buildings
-- PRIMARY KEY per la tabella della classe : Buildings - BUILDINGS
--
ALTER TABLE buildings ADD CONSTRAINT buildings_PK PRIMARY KEY (classid);
--
-- TABLE CONSTRAINT: installation
-- FOREIGN KEY per la tabella della classe : Installation - INSTALLATION
--
ALTER TABLE installation ADD CONSTRAINT installation_FK1 FOREIGN KEY (condition) REFERENCES d_conditionofconstruction (code) ;
ALTER TABLE installation ADD CONSTRAINT installation_FK2 FOREIGN KEY (elev_ref) REFERENCES d_elevationreference (code) ;
ALTER TABLE installation ADD CONSTRAINT installation_FK3 FOREIGN KEY (height_height_low) REFERENCES d_elevationreference (code) ;
ALTER TABLE installation ADD CONSTRAINT installation_FK4 FOREIGN KEY (height_height_ref) REFERENCES d_elevationreference (code) ;
ALTER TABLE installation ADD CONSTRAINT installation_FK5 FOREIGN KEY (height_height_stat) REFERENCES d_heightstatus (code) ;
ALTER TABLE installation ADD CONSTRAINT installation_FK6 FOREIGN KEY (installation_nature) REFERENCES d_installationnature (code) ;
ALTER TABLE installation ADD CONSTRAINT installation_FK7 FOREIGN KEY (ownership) REFERENCES h_ownershiptype (code) ;
ALTER TABLE installation ADD CONSTRAINT installation_FK8 FOREIGN KEY (type) REFERENCES d_type_value (code) ;
--
-- TABLE CONSTRAINT: thermalzone
-- FOREIGN KEY per la tabella della classe : Thermal zone (building part) - THERMALZONE
--
ALTER TABLE thermalzone ADD CONSTRAINT thermalzone_FK1 FOREIGN KEY (energyperformance_perf_class) REFERENCES d_perf_class (code) ;
ALTER TABLE thermalzone ADD CONSTRAINT thermalzone_FK2 FOREIGN KEY (energyperformance_perf_uom) REFERENCES h_uom (code) ;
ALTER TABLE thermalzone ADD CONSTRAINT thermalzone_FK3 FOREIGN KEY (occupants_occ_type) REFERENCES d_occupancytype (code) ;
ALTER TABLE thermalzone ADD CONSTRAINT thermalzone_FK4 FOREIGN KEY (tz2bdg) REFERENCES buildings (classid) ;
--
-- TABLE CONSTRAINT: conversion
-- FOREIGN KEY per la tabella della classe : Conversion class - CONVERSION
--
ALTER TABLE conversion ADD CONSTRAINT conversion_FK1 FOREIGN KEY (input) REFERENCES h_uom (code) ;
ALTER TABLE conversion ADD CONSTRAINT conversion_FK2 FOREIGN KEY (location) REFERENCES h_location (code) ;
ALTER TABLE conversion ADD CONSTRAINT conversion_FK3 FOREIGN KEY (output) REFERENCES h_uom (code) ;
--
-- TABLE CONSTRAINT: buildings
-- FOREIGN KEY per la tabella della classe : Buildings - BUILDINGS
--
ALTER TABLE buildings ADD CONSTRAINT buildings_FK1 FOREIGN KEY (buildingtype) REFERENCES d_buildingtype (code) ;
ALTER TABLE buildings ADD CONSTRAINT buildings_FK2 FOREIGN KEY (condition) REFERENCES d_conditionofconstruction (code) ;
ALTER TABLE buildings ADD CONSTRAINT buildings_FK3 FOREIGN KEY (elev_ref) REFERENCES d_elevationreference (code) ;
ALTER TABLE buildings ADD CONSTRAINT buildings_FK4 FOREIGN KEY (height_height_low) REFERENCES d_elevationreference (code) ;
ALTER TABLE buildings ADD CONSTRAINT buildings_FK5 FOREIGN KEY (height_height_ref) REFERENCES d_elevationreference (code) ;
ALTER TABLE buildings ADD CONSTRAINT buildings_FK6 FOREIGN KEY (height_height_stat) REFERENCES d_heightstatus (code) ;
ALTER TABLE buildings ADD CONSTRAINT buildings_FK7 FOREIGN KEY (nature) REFERENCES d_buildingnature (code) ;
ALTER TABLE buildings ADD CONSTRAINT buildings_FK8 FOREIGN KEY (ownership) REFERENCES h_ownershiptype (code) ;
ALTER TABLE buildings ADD CONSTRAINT buildings_FK9 FOREIGN KEY (refurbish) REFERENCES d_refurbishmentlevel (code) ;
ALTER TABLE buildings ADD CONSTRAINT buildings_FK10 FOREIGN KEY (roof_type) REFERENCES d_rooftype (code) ;
ALTER TABLE buildings ADD CONSTRAINT buildings_FK11 FOREIGN KEY (use_s) REFERENCES h_currentuse (code) ;
--
-- Generazione PK e FK per attributi multivalore
--
--
-- TABLE CONSTRAINT: thermalzone_heatingsystem
-- FOREIGN KEY per la tabella dell'attributo multivalore : heatingsystem - heatingSystem
--
ALTER TABLE thermalzone_heatingsystem ADD CONSTRAINT thermalzone_heatingsystem_FK1 FOREIGN KEY (classref) REFERENCES thermalzone (classid) ;
ALTER TABLE thermalzone_heatingsystem ADD CONSTRAINT thermalzone_heatingsystem_FK2 FOREIGN KEY (heatingsystem) REFERENCES d_heatingsystem (code) ;
ALTER TABLE thermalzone_heatingsystem ADD CONSTRAINT thermalzone_heatingsystem_PK PRIMARY KEY (classref ,heatingsystem );
--
-- TABLE CONSTRAINT: thermalzone_heatingsource
-- FOREIGN KEY per la tabella dell'attributo multivalore : heatingsource - heatingSource
--
ALTER TABLE thermalzone_heatingsource ADD CONSTRAINT thermalzone_heatingsource_FK1 FOREIGN KEY (classref) REFERENCES thermalzone (classid) ;
ALTER TABLE thermalzone_heatingsource ADD CONSTRAINT thermalzone_heatingsource_FK2 FOREIGN KEY (heatingsource) REFERENCES h_energysource (code) ;
ALTER TABLE thermalzone_heatingsource ADD CONSTRAINT thermalzone_heatingsource_PK PRIMARY KEY (classref ,heatingsource );
--
-- TABLE CONSTRAINT: buildings_structure_mat
-- FOREIGN KEY per la tabella dell'attributo multivalore : material of structure - STRUCTURE_MAT
--
ALTER TABLE buildings_structure_mat ADD CONSTRAINT buildings_structure_mat_FK1 FOREIGN KEY (classref) REFERENCES buildings (classid) ;
ALTER TABLE buildings_structure_mat ADD CONSTRAINT buildings_structure_mat_FK2 FOREIGN KEY (structure_mat) REFERENCES d_material (code) ;
ALTER TABLE buildings_structure_mat ADD CONSTRAINT buildings_structure_mat_PK PRIMARY KEY (classref ,structure_mat );
--
-- TABLE CONSTRAINT: buildings_facade_mat
-- FOREIGN KEY per la tabella dell'attributo multivalore : material of facade - FACADE_MAT
--
ALTER TABLE buildings_facade_mat ADD CONSTRAINT buildings_facade_mat_FK1 FOREIGN KEY (classref) REFERENCES buildings (classid) ;
ALTER TABLE buildings_facade_mat ADD CONSTRAINT buildings_facade_mat_FK2 FOREIGN KEY (facade_mat) REFERENCES d_material (code) ;
ALTER TABLE buildings_facade_mat ADD CONSTRAINT buildings_facade_mat_PK PRIMARY KEY (classref ,facade_mat );
--
-- TABLE CONSTRAINT: buildings_roof_mat
-- FOREIGN KEY per la tabella dell'attributo multivalore : material of roof - ROOF_MAT
--
ALTER TABLE buildings_roof_mat ADD CONSTRAINT buildings_roof_mat_FK1 FOREIGN KEY (classref) REFERENCES buildings (classid) ;
ALTER TABLE buildings_roof_mat ADD CONSTRAINT buildings_roof_mat_FK2 FOREIGN KEY (roof_mat) REFERENCES d_material (code) ;
ALTER TABLE buildings_roof_mat ADD CONSTRAINT buildings_roof_mat_PK PRIMARY KEY (classref ,roof_mat );
--
-- Generazione PK e FK per i datatype
--
--
-- TABLE CONSTRAINT: thermalzone_energyamount_t
-- PRIMARY KEY e FOREIGN KEY per la tabella delle associzione binaria con attributi: Energy amount - EnergyAmount
--
ALTER TABLE thermalzone_energyamount_t ADD CONSTRAINT thermalzone_energyamount_t_FK1 FOREIGN KEY (classref) REFERENCES thermalzone (classid) ;
ALTER TABLE thermalzone_energyamount_t ADD CONSTRAINT thermalzone_energyamount_t_FK2 FOREIGN KEY (energyamount_e_source) REFERENCES h_energysource (code) ;
ALTER TABLE thermalzone_energyamount_t ADD CONSTRAINT thermalzone_energyamount_t_FK3 FOREIGN KEY (energyamount_e_type) REFERENCES d_energytype (code) ;
ALTER TABLE thermalzone_energyamount_t ADD CONSTRAINT thermalzone_energyamount_t_FK4 FOREIGN KEY (energyamount_e_use) REFERENCES d_energyuse (code) ;
ALTER TABLE thermalzone_energyamount_t ADD CONSTRAINT thermalzone_energyamount_t_FK5 FOREIGN KEY (energyamount_e_uom) REFERENCES h_uom (code) ;
ALTER TABLE thermalzone_energyamount_t ADD CONSTRAINT thermalzone_energyamount_t_PK PRIMARY KEY (classref ,energyamount_e_amount ,energyamount_e_source ,energyamount_e_type ,energyamount_e_use ,energyamount_e_year ,energyamount_e_uom ,energyamount_estimatedco2 );
--
-- TABLE CONSTRAINT: buildings_energyamount_t
-- PRIMARY KEY e FOREIGN KEY per la tabella delle associzione binaria con attributi: Energy amount - EnergyAmount
--
ALTER TABLE buildings_energyamount_t ADD CONSTRAINT buildings_energyamount_t_FK1 FOREIGN KEY (classref) REFERENCES buildings (classid) ;
ALTER TABLE buildings_energyamount_t ADD CONSTRAINT buildings_energyamount_t_FK2 FOREIGN KEY (energyamount_e_source) REFERENCES h_energysource (code) ;
ALTER TABLE buildings_energyamount_t ADD CONSTRAINT buildings_energyamount_t_FK3 FOREIGN KEY (energyamount_e_type) REFERENCES d_energytype (code) ;
ALTER TABLE buildings_energyamount_t ADD CONSTRAINT buildings_energyamount_t_FK4 FOREIGN KEY (energyamount_e_use) REFERENCES d_energyuse (code) ;
ALTER TABLE buildings_energyamount_t ADD CONSTRAINT buildings_energyamount_t_FK5 FOREIGN KEY (energyamount_e_uom) REFERENCES h_uom (code) ;
ALTER TABLE buildings_energyamount_t ADD CONSTRAINT buildings_energyamount_t_PK PRIMARY KEY (classref ,energyamount_e_amount ,energyamount_e_source ,energyamount_e_type ,energyamount_e_use ,energyamount_e_year ,energyamount_e_uom ,energyamount_estimatedco2 );
--
-- TABLE CONSTRAINT: installation_ext_ref_t
-- PRIMARY KEY e FOREIGN KEY per la tabella delle associzione binaria con attributi: External reference - EXT_REF
--
ALTER TABLE installation_ext_ref_t ADD CONSTRAINT installation_ext_ref_t_FK1 FOREIGN KEY (classref) REFERENCES installation (classid) ;
ALTER TABLE installation_ext_ref_t ADD CONSTRAINT installation_ext_ref_t_PK PRIMARY KEY (classref ,ext_ref_identifier ,ext_ref_inf_sys_name ,ext_ref_reference );
--
-- TABLE CONSTRAINT: thermalzone_officialarea_t
-- PRIMARY KEY e FOREIGN KEY per la tabella delle associzione binaria con attributi: Official area - OFF_AREA
--
ALTER TABLE thermalzone_officialarea_t ADD CONSTRAINT thermalzone_officialarea_t_FK1 FOREIGN KEY (classref) REFERENCES thermalzone (classid) ;
ALTER TABLE thermalzone_officialarea_t ADD CONSTRAINT thermalzone_officialarea_t_FK2 FOREIGN KEY (officialarea_area_ref) REFERENCES d_clge (code) ;
ALTER TABLE thermalzone_officialarea_t ADD CONSTRAINT thermalzone_officialarea_t_PK PRIMARY KEY (classref ,officialarea_area_ref ,officialarea_value );
--
-- TABLE CONSTRAINT: buildings_ext_ref_t
-- PRIMARY KEY e FOREIGN KEY per la tabella delle associzione binaria con attributi: External reference - EXT_REF
--
ALTER TABLE buildings_ext_ref_t ADD CONSTRAINT buildings_ext_ref_t_FK1 FOREIGN KEY (classref) REFERENCES buildings (classid) ;
ALTER TABLE buildings_ext_ref_t ADD CONSTRAINT buildings_ext_ref_t_PK PRIMARY KEY (classref ,ext_ref_identifier ,ext_ref_inf_sys_name ,ext_ref_reference );
--
-- TABLE CONSTRAINT: installation_elevation_t
-- PRIMARY KEY e FOREIGN KEY per la tabella delle associzione binaria con attributi: Elevation - ELEVATION
--
ALTER TABLE installation_elevation_t ADD CONSTRAINT installation_elevation_t_FK1 FOREIGN KEY (classref) REFERENCES installation (classid) ;
ALTER TABLE installation_elevation_t ADD CONSTRAINT installation_elevation_t_FK2 FOREIGN KEY (elevation_elevationreference) REFERENCES d_elevationreference (code) ;
ALTER TABLE installation_elevation_t ADD CONSTRAINT installation_elevation_t_PK UNIQUE (classref ,elevation_elev_val ,elevation_elevationreference );
--
-- TABLE CONSTRAINT: buildings_use_m_t
-- PRIMARY KEY e FOREIGN KEY per la tabella delle associzione binaria con attributi: Current use - CURR_USE
--
ALTER TABLE buildings_use_m_t ADD CONSTRAINT buildings_use_m_t_FK1 FOREIGN KEY (classref) REFERENCES buildings (classid) ;
ALTER TABLE buildings_use_m_t ADD CONSTRAINT buildings_use_m_t_FK2 FOREIGN KEY (use_m_currentuse) REFERENCES h_currentuse (code) ;
ALTER TABLE buildings_use_m_t ADD CONSTRAINT buildings_use_m_t_PK PRIMARY KEY (classref ,use_m_currentuse ,use_m_percentage );
--
-- TABLE CONSTRAINT: buildings_elevation_t
-- PRIMARY KEY e FOREIGN KEY per la tabella delle associzione binaria con attributi: Elevation - ELEVATION
--
ALTER TABLE buildings_elevation_t ADD CONSTRAINT buildings_elevation_t_FK1 FOREIGN KEY (classref) REFERENCES buildings (classid) ;
ALTER TABLE buildings_elevation_t ADD CONSTRAINT buildings_elevation_t_FK2 FOREIGN KEY (elevation_elevationreference) REFERENCES d_elevationreference (code) ;
ALTER TABLE buildings_elevation_t ADD CONSTRAINT buildings_elevation_t_PK UNIQUE (classref ,elevation_elev_val ,elevation_elevationreference );
--