-
Notifications
You must be signed in to change notification settings - Fork 5
/
postgeol_structure_01_tables.sql
2891 lines (2709 loc) · 173 KB
/
postgeol_structure_01_tables.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
/*
_______________ENCOURS_______________GEOLLLIBRE */
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
-- TODO LISTE:{{{
-- o faire un schéma pour les données; voir comment paramétrer ça: variable d'environnement? Option dans gll_preferences? Nom arbitraire ("data") gravé dans le marbre? Des schémas par ensemble logique de données (drilling, field, geophy, geotech...)
-- o faire le rôle data_admin, et les autres rôles "génériques" (groupes)
-- o d'autres rôles du genre db_admin, data_entry, data_query, etc.
-- e mettre des types comme conseillé dans (? cf. twitter), par exemple des TEXT au lieu de VARCHAR => bigserial au lieu de serial: fait; ...
-- => ce fut une mauvaise idée: postgis requiert, apparemment, une clé en int4; donc un serial; je rechange tout.
-- o chercher un algorithme de géocodage street address => lat-lon ==> BAN => implémenter sous forme:
-- o de traitement par lots:
-- o export en .csv des données pour lesquelles on veut un géocodage
-- o appel de l'API
-- o recueil des données traitées
-- o jointure et requête de mise à jour de la table originelle (ou information dans une autre table)
-- o de traitement par enregistrement (sur trigger de modification ou d'ajout, par exemple): appel à l'API directement depuis un script, et mise à jour au vol de l'enregistrement (ou information dans une autre table)
-- o check all owners to data_admin
-- o ajouter des CONSTRAINT PRIMARY KEY où nécessaire, ou plutôt des trucs comme: ("CREATE TABLE test (id bigserial PRIMARY KEY, num integer, data text);")
-- o mettre des NOT NULL un peu partout
-- o Il faudrait lancer ce script comme un administrateur,
-- avec des arguments:
-- - le ou les rôle(s) "utilisateur lambda" à utiliser;
-- - le ou les rôles "utilisateur admin"
-- - le nom de la base à créer, si différent de $POSTGEOL
-- Quelque chose dans le genre:
-- psql -v normal_user="chantal, gaston" -v data_admin="pierre, marie" -v db_admin = "pierre" -v postgeol_newdb_name="test_postgeol" -f postgeol_structure.sql
-- :normal_user
-- fait:{{{
-- x mettre les numauto en: numauto bigserial UNIQUE NOT NULL,
-- x mettre tous les numauto en bigserial PRIMARY KEY
-- x mettre tous les: REFERENCES operations (opid)
--}}}
-- }}}
-- En-tête, copyright {{{
-- Title: "Structure of POSTGEOL database: PostgreSQL database for GEOLogical data"
-- Author: "Pierre Chevalier"
-- License: {
-- This file is part of GeolLLibre software suite: FLOSS dedicated to Earth Sciences.
-- ###########################################################################
-- ## ____ ___/_ ____ __ __ __ _()____ ____ _____ ##
-- ## / ___\/ ___// _ |/ / / / / / / _/ _ \ / __ \/ ___/ ##
-- ## / /___/ /_ / / | / / / / / / / // /_/_/ /_/ / /_ ##
-- ## / /_/ / /___| \/ / /__/ /__/ /___/ // /_/ / _, _/ /___ ##
-- ## \____/_____/ \___/_____/___/_____/__/_____/_/ |_/_____/ ##
-- ## ##
-- ###########################################################################
-- Copyright (C) 2019 Pierre Chevalier <pierrechevaliergeol@free.fr>
--
-- GeolLLibre is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>
-- or write to the Free Software Foundation, Inc., 51 Franklin Street,
-- Fifth Floor, Boston, MA 02110-1301, USA.
-- See LICENSE file.
--}
--}}}
-- Create schemas:{{{
-- CREATE SCHEMA data;
-- COMMENT ON SCHEMA data IS 'Schema where data tables actually are'; -- in fact not; TODO to be done later on
CREATE SCHEMA checks;
COMMENT ON SCHEMA checks IS 'Views selecting unconsistent, incoherent, unprobable data: useful to chase incorrect data';
CREATE SCHEMA gdm;
COMMENT ON SCHEMA gdm IS 'Views for connection with GDM software through ODBC';
CREATE SCHEMA input;
COMMENT ON SCHEMA input IS 'Tables with same structure as tables in main data schema: for data input before validation and dump into final tables (apparently unused on production site 2013_08_03__11_40_18).';
CREATE SCHEMA stats_reports;
COMMENT ON SCHEMA stats_reports IS 'Views with statistics and reports, for daily/weekly/monthly statistics.';
CREATE SCHEMA tmp_imports;
COMMENT ON SCHEMA tmp_imports IS 'Temporary place for imported files. Tables imported from .csv files by using the csv2sql utility are going in this schema. Also refer to .gll_preferences file.';
CREATE SCHEMA backups;
COMMENT ON SCHEMA backups IS 'Just in case, a convenient place to put table backups when potentially dangerous changes are to be made.';
--}}}
-- Create tables:{{{
--SET SCHEMA_DATA = 'public'; -- for the time being. Eventually, data tables will be moved into another work schema.
--SET search_path = SCHEMA_DATA, pg_catalog;
--SET search_path = '$user', 'public';
--SET search_path = public, pg_catalog;
-- organisation: --TODO make a super-master table, in order to group operations: useful in case of a group of large consultant companies, for instance.
-- orgid field should be added to all tables downstream, and taken into account in all relationships. Boudiou.
-- x operations:{{{
CREATE TABLE public.operations (
opid serial PRIMARY KEY NOT NULL,
name_short text, --NOT NULL, -- TODO warning: field previously named differently: operation
name_full text, --NOT NULL, -- TODO warning: field previously named differently: full_name
year integer DEFAULT substring(now()::text, 0, 5)::integer, -- Careful at the end of year 9999. -- NOT NULL, -- => NULL autorisé, tout bien pesé
confidentiality boolean NOT NULL DEFAULT TRUE,
operator text, --NOT NULL,
address1_street text,
address2_parcell text,
address3_areacode text,
address4_zipcode text,
address5_town text,
srid text,
x numeric,
y numeric,
accuracy integer,
lon_min numeric(10,5), --NOT NULL,
lat_min numeric(10,5), --NOT NULL,
lon_max numeric(10,5), --NOT NULL,
lat_max numeric(10,5), --NOT NULL,
boundary_geom geometry,
geography_4326 geography,
comments text, --NOT NULL,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user NOT NULL
--numauto serial UNIQUE NOT NULL, -- useless, since opid is already the serial PRIMARY KEY
);
COMMENT ON TABLE public.operations IS 'Operations, projects: master table, to be queried all the time, especially for confidentiality purposes.';
COMMENT ON COLUMN public.operations.opid IS 'Operation identifier, automatic sequence; referred by all tables, since all data contained belongs to an operation';
-- TODO *ideally*, to avoid any collisions, a centralised operations reference should be put in place, worldwide, so that, throughout the world and among all postgeol users, an opid would always be fully significant. An "operation creation" procedure is something quite rare, and it should therefore be done online, whereas all subsequent work can be done off Internet. In some cases, an "operation creation" is not something rare, though.
COMMENT ON COLUMN public.operations.name_short IS 'Operation short name, aka code';
COMMENT ON COLUMN public.operations.name_full IS 'Complete operation name';
COMMENT ON COLUMN public.operations.year IS 'Year of operation activity';
COMMENT ON COLUMN public.operations.confidentiality IS 'Confidentiality flag, true or false; default is true';
COMMENT ON COLUMN public.operations.operator IS 'Operator: mining operator, exploration company, client name';
COMMENT ON COLUMN public.operations.address1_street IS 'There are several approaches to the operation location. In environments with road infrastructures, etc.: location is expressed as street address in plain text, for further computation and georeferenciation';
COMMENT ON COLUMN public.operations.address2_parcell IS 'Parcels numbers, if relevant';
COMMENT ON COLUMN public.operations.address3_areacode IS 'Area code, for instance "32"';
COMMENT ON COLUMN public.operations.address4_zipcode IS 'Zip code, without the area code, for instance "100"';
COMMENT ON COLUMN public.operations.address5_town IS 'Town name, for instance "Grazimis"';
COMMENT ON COLUMN public.operations.srid IS 'Spatial Reference Identifier, or coordinate reference system: see spatial_ref_sys from postgis extension';
COMMENT ON COLUMN public.operations.x IS 'X coordinate (Easting), in coordinate system srid';
COMMENT ON COLUMN public.operations.y IS 'Y coordinate (Northing), in coordinate system srid';
COMMENT ON COLUMN public.operations.accuracy IS 'Location by x, y coordinates quality: -1 worst, 3 best (according to algorithm used, for instance, from street_address field to inform x, y fields; if changed manually, change accuracy to something better (TODO check used lexicon on historical CRM). Note that this would be an approximation of a punctual operation only';
COMMENT ON COLUMN public.operations.lat_min IS 'Another approach to location, by latitudes and longitudes min-max. South latitude, decimal degrees, WGS84';
COMMENT ON COLUMN public.operations.lon_min IS 'West longitude, decimal degrees, WGS84';
COMMENT ON COLUMN public.operations.lat_max IS 'North latitude, decimal degrees, WGS84';
COMMENT ON COLUMN public.operations.lon_max IS 'East latitude, decimal degrees, WGS84';
COMMENT ON COLUMN public.operations.boundary_geom IS 'Yet another way to locate an operation: a geometry, most often a polygon following the boundary surrounding the operation zone. All these location solutions can be used with a sort of priority order, with spatial queries returning such or such location type, accordingly. In the long term, however, those fields should be somehow trimmed';
COMMENT ON COLUMN public.operations.geography_4326 IS 'Geographic position, in longitude-latitude according to WGS84 ellipsoid, aka EPSG 4326';
COMMENT ON COLUMN public.operations.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.operations.username IS 'User (role) which created data record';
--COMMENT ON COLUMN public.operations.numauto IS 'Automatic integer';
--}}}
-- x operation_active:{{{
CREATE TABLE :USER.operation_active ( -- TODO at some point, put back some logic in the SCHEMAs organisation.
opid integer PRIMARY KEY NOT NULL
REFERENCES public.operations (opid)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED,
-- numauto serial PRIMARY KEY, -- BOF, on pourrait s'en passer
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user
-- UNIQUE (opid) -- on s'en passe
);
COMMENT ON TABLE :USER.operation_active IS 'Table containing active opid(s), in order to query only some operations by systematically JOINing on opid; homonymous views (same name as public.tables in user schema are doing this seamlessly, once operation_active is properly filled.'; -- TODO add a constraint per user - authorised opid(s)
COMMENT ON COLUMN :USER.operation_active.opid IS 'Operation identifier';
-- COMMENT ON COLUMN :USER.operation_active.numauto IS 'Automatic integer';
COMMENT ON COLUMN :USER.operation_active.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN :USER.operation_active.username IS 'User (role) which created data record';
--}}}
-- x field work, on surface:{{{ -- discussion ended: prefix these tables with surface_
-- x surface_observations:{{{
-- TODO ATTENTION!!! DU REFACTORING À FAIRE DANS TOUTE LA BASE DE CODE!
CREATE TABLE public.surface_observations (
opid integer NOT NULL
REFERENCES public.operations (opid)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED,
obs_id text NOT NULL,
year integer, --NOT NULL,
date date, --NOT NULL, -- TODO virer ce champ, après avoir, dans les données historiques, combiné son contenu avec la date pour en faire un format timestamp ou équivalent (ou pas...)
time text, --NOT NULL, -- TODO voir ce que contient ce champ; le renommer mieux => moui.
srid integer NOT NULL,
x numeric(20,10) NOT NULL,
y numeric(20,10) NOT NULL,
z numeric(20, 2), -- NOT NULL,
geometry_corr geometry,
geography_4326 geography,
description text, --NOT NULL,
code_litho text, --NOT NULL,
code_unit text, --NOT NULL,
sample_id text, --NOT NULL,
audio text, --NOT NULL,
photos text, --NOT NULL,
geologist text, --NOT NULL,
device text, --NOT NULL,
comments text, --NOT NULL,
datasource integer, --NOT NULL,
waypoint_name text, --NOT NULL,
icon_descr text, --NOT NULL, -- Eventually get rid of this quite useless field.
timestamp_epoch_ms bigint, -- NOT NULL,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text NOT NULL DEFAULT current_user,
UNIQUE (opid, obs_id)
);
COMMENT ON TABLE public.surface_observations IS 'Surface, or field, observations: geological observations, on outcrops, floats, or any other observations; coherent with GeolPDA';
COMMENT ON COLUMN public.surface_observations.opid IS 'Operation identifier';
COMMENT ON COLUMN public.surface_observations.obs_id IS 'Observation identifier: usually composed of: (acronym of person)_(year)_(incremental integer)';
COMMENT ON COLUMN public.surface_observations.year IS 'Year when observation is done (TODO DROP COLUMN redundant with date field)';
COMMENT ON COLUMN public.surface_observations.date IS 'Observation date';
COMMENT ON COLUMN public.surface_observations.waypoint_name IS 'If relevant, waypoint name from GPS device';
COMMENT ON COLUMN public.surface_observations.srid IS 'Spatial Reference Identifier, or coordinate reference system: see spatial_ref_sys from postgis extension';
COMMENT ON COLUMN public.surface_observations.x IS 'X coordinate (Easting), in coordinate system srid';
COMMENT ON COLUMN public.surface_observations.y IS 'Y coordinate (Northing), in coordinate system srid';
COMMENT ON COLUMN public.surface_observations.z IS 'Z coordinate';
COMMENT ON COLUMN public.surface_observations.geometry_corr IS 'Manually corrected geometry: this is typically used when a GPS location turns out to be wrong, and that elements allow to better define the actual location of the observation point (field measurements, orthophoto mapping, etc.); when not NULL, this field should be used by cartographic VIEWs depending on this relation, instead of x, y fields'; -- TODO reprendre les positions des waypoints au SGR/REU, dont certains avaient été bougés "à la main" dans MapInfect, ce qui amène à avoir des x, y différents de la géométrie. Pour ce cas, on stockera la géométrie de MapInfect dans ce champ et les champs numériques (non précis) dans les champs ci-dessus.
COMMENT ON COLUMN public.surface_observations.geography_4326 IS 'Geographic position, in longitude-latitude according to WGS84 ellipsoid, aka EPSG 4326';
COMMENT ON COLUMN public.surface_observations.description IS 'Naturalist description';
COMMENT ON COLUMN public.surface_observations.code_litho IS 'Lithological code';
COMMENT ON COLUMN public.surface_observations.code_unit IS 'Unit code: lithostratigraphic, and/or cartographic';
COMMENT ON COLUMN public.surface_observations.sample_id IS 'If relevant, sample identifier';
COMMENT ON COLUMN public.surface_observations.audio IS 'Audio recording files, if relevant';
COMMENT ON COLUMN public.surface_observations.photos IS 'List of photographs pictures files, if relevant';
COMMENT ON COLUMN public.surface_observations.geologist IS 'Geologist or prospector name';
COMMENT ON COLUMN public.surface_observations.device IS 'Device used to record data: good old fieldbook, PDA, smartphone, tablet, dictaphone, raw human memory (not recommended), etc.';
COMMENT ON COLUMN public.surface_observations.icon_descr IS 'If relevant, icon description from some GPS devices/programs';
COMMENT ON COLUMN public.surface_observations.comments IS 'Comments';
COMMENT ON COLUMN public.surface_observations.time IS '?';
COMMENT ON COLUMN public.surface_observations.timestamp_epoch_ms IS 'Timestamp of observation: as defined in GeolPDA devices, as epoch in ms';
COMMENT ON COLUMN public.surface_observations.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.surface_observations.numauto IS 'Automatic integer primary key';
COMMENT ON COLUMN public.surface_observations.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.surface_observations.username IS 'User (role) which created data record';
--}}}
-- x surface_observations_struct_measures:{{{
CREATE TABLE public.surface_observations_struct_measures (
opid integer NOT NULL,
obs_id text NOT NULL,
measure_type text NOT NULL,
device text NOT NULL,
structure_type text ,
rotation_matrix text NOT NULL,
north_ref text NOT NULL,
direction integer NOT NULL,
dip integer NOT NULL,
dip_quadrant text NOT NULL,
pitch integer NOT NULL,
pitch_quadrant text NOT NULL,
movement text NOT NULL,
valid boolean NOT NULL,
comments text NOT NULL,
geolpda_id integer NOT NULL,
geolpda_poi_id integer NOT NULL,
sortgroup text NOT NULL,
datasource integer NOT NULL,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user,
FOREIGN KEY (opid, obs_id)
REFERENCES public.surface_observations(opid, obs_id)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED
);
COMMENT ON TABLE public.surface_observations_struct_measures IS 'Structural measurements, related to an observation; coherent with GeolPDA';
COMMENT ON COLUMN public.surface_observations_struct_measures.opid IS 'Operation identifier';
COMMENT ON COLUMN public.surface_observations_struct_measures.obs_id IS 'Observation identifier: refers to surface_observations table';
COMMENT ON COLUMN public.surface_observations_struct_measures.measure_type IS 'Type of measurement: [P: plane L: line PL: plane line PLM: plane line movement PLMS: plane line movement sure]';
COMMENT ON COLUMN public.surface_observations_struct_measures.device IS 'Measuring device: compass, electronic device';
COMMENT ON COLUMN public.surface_observations_struct_measures.structure_type IS 'Measured structure type: [VEIN , FRACTURE , C , SCHISTOSITY , FOLIATION , MYLONITE , CONTACT , VEIN_FAULT , FOLD_PAX_AX , FOLIATION_LINE , FAULT , CATACLASE , MINERALISED_STRUCTURE]';
COMMENT ON COLUMN public.surface_observations_struct_measures.rotation_matrix IS '3x3 rotation matrix, fully describing any orientation: initial state: [X axis points East, Y axis points North, Z axis points up] => measurement state = rotation applied. Corresponds to function public static float[] getOrientation (float[] R, float[] values) from android API as described in http://developer.android.com/reference/android/hardware/SensorManager.html#getOrientation%28float[],%20float[]%29';
COMMENT ON COLUMN public.surface_observations_struct_measures.north_ref IS 'North reference for azimuths and directions measurements: [Nm: magnetic North, Ng: geographic North, Nu: UTM north, Nl: local grid Y axis]';
COMMENT ON COLUMN public.surface_observations_struct_measures.direction IS 'Plane direction, 0-180°';
COMMENT ON COLUMN public.surface_observations_struct_measures.dip IS 'Plane dip, 0-90°';
COMMENT ON COLUMN public.surface_observations_struct_measures.dip_quadrant IS 'Plane dip quadrant, NESW';
COMMENT ON COLUMN public.surface_observations_struct_measures.pitch IS 'Pitch of line on plane, 0-90°';
COMMENT ON COLUMN public.surface_observations_struct_measures.pitch_quadrant IS 'Quadrant of pitch, NESW';
COMMENT ON COLUMN public.surface_observations_struct_measures.movement IS 'Relative movement of fault/C: [N: normal, I: inverse = R = reverse, D: dextral, S: sinistral]';
COMMENT ON COLUMN public.surface_observations_struct_measures.valid IS 'Measure is valid or not (impossible cases = not valid)';
COMMENT ON COLUMN public.surface_observations_struct_measures.comments IS 'Comments';
COMMENT ON COLUMN public.surface_observations_struct_measures.geolpda_id IS 'If a GeolPDA was used to measure the orientation, copy of geolpda_id field';
COMMENT ON COLUMN public.surface_observations_struct_measures.geolpda_poi_id IS 'If a GeolPDA was used to measure the orientation, copy of geolpda_poi_id field';
--COMMENT ON COLUMN public.surface_observations_struct_measures.sortgroup IS 'Sorting group, for discriminated of various phases: a, b, c, ...';
COMMENT ON COLUMN public.surface_observations_struct_measures.sortgroup IS 'In case of sorting structural measurements using TecTri or similar, letter referring to sort group (corresponding to various phases): a, b, c, ...';
COMMENT ON COLUMN public.surface_observations_struct_measures.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.surface_observations_struct_measures.numauto IS 'Automatic integer primary key';
COMMENT ON COLUMN public.surface_observations_struct_measures.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.surface_observations_struct_measures.username IS 'User (role) which created data record';
--}}}
-- x surface_photos:{{{ -- TODO rather make a general-purpose "photos" table, containing all photogaphs, referred by numerous tables through various keys, with integrity references to be implemented carefully.
-- table vide, pour le moment.
CREATE TABLE public.surface_photos (
opid integer
REFERENCES public.operations (opid)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED,
pho_id text NOT NULL,
obs_id text, -- est-ce bien pertinent de faire cela? Ne serait-ce pas plus opportun de faire une table "photos", qui se fasse pointer par surface_observations ou par dh_litho ou par dh_sampling ou par... À voir. <= oui, voilà... cf. supra
filename text, --x TODO "file" => reserved word? appears pinkish in vim with SQL highlighting: rename to filename, if necessary? => done
description text,
azim_nm numeric, --WARNING, field renamed from az to something a bit more meaningful; however, maybe azim_ng should be preferable: TODO later.
dip_hz numeric, --WARNING, field renamed from dip to something a bit more meaningful.
author text, --hm, useful? Geologist from surface_observations should do it, no? TODO drop this field, if unnecessary.
datasource integer,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user
--FOREIGN KEY (opid, obs_id) REFERENCES public.surface_observations(opid, obs_id)
-- => Non: Notons au passage qu'une photo ne va pas forcément avec un point d'observation.
-- Mais à ce moment, il faudrait lui prévoir un moyen de la géolocaliser?
-- On pourrait faire une table points, tout bêtement, où les tables surface_observations et surface_photos iraient stocker leurs géolocalisations. Hm. TODO y réfléchir. C'est quand même pratique, les struct du C, à la place de ce genre de choses.
-- FOREIGN KEY (opid) REFERENCES public.operations(opid)
-- ON DELETE CASCADE
-- ON UPDATE CASCADE
-- DEFERRABLE INITIALLY DEFERRED
);
COMMENT ON TABLE public.surface_photos IS 'Photographs taken in field, related to an observation';
COMMENT ON COLUMN public.surface_photos.opid IS 'Operation identifier';
COMMENT ON COLUMN public.surface_photos.pho_id IS 'Photograph identifier';
COMMENT ON COLUMN public.surface_photos.filename IS 'Photograph full filename, with relative or full path included; to be made consistent and usable';
COMMENT ON COLUMN public.surface_photos.azim_nm IS 'Azimuth of camera axis, refers to magnetic North (°)';
COMMENT ON COLUMN public.surface_photos.dip_hz IS 'Dip of camera axis, relative to horizontal (°)';
COMMENT ON COLUMN public.surface_photos.author IS 'Photograph author; not very useful, as it generally is the geologist, as defined in surface_observations table';
COMMENT ON COLUMN public.surface_photos.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.surface_photos.numauto IS 'Automatic integer';
COMMENT ON COLUMN public.surface_photos.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.surface_photos.username IS 'User (role) which created data record';
--}}}
-- x formations_group_lithos:{{{
CREATE TABLE public.formations_group_lithos ( -- TODO name formations_group_lithos is discutable; formations_lithostrati would be better?
opid integer
REFERENCES public.operations(opid)
ON DELETE CASCADE
ON UPDATE CASCADE
DEFERRABLE INITIALLY DEFERRED,
formation_name text,
code_litho text,
datasource integer,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user
);
COMMENT ON TABLE public.formations_group_lithos IS 'Groups of lithologies, for simplification; typically for mapping outcrop points, or plotting drill holes sections';
COMMENT ON COLUMN public.formations_group_lithos.opid IS 'Operation identifier';
COMMENT ON COLUMN public.formations_group_lithos.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.formations_group_lithos.numauto IS 'Automatic integer primary key';
COMMENT ON COLUMN public.formations_group_lithos.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.formations_group_lithos.username IS 'User (role) which created data record';
--}}}
-- x surface_samples_grades:{{{
CREATE TABLE public.surface_samples_grades (
opid integer
REFERENCES public.operations (opid)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED,
sample_id text,
srid integer,
x numeric,
y numeric,
z numeric,
description text,
sample_type text,
outcrop_id text,
trend text,
dip text,
length_m text,
width_m text,
au1_ppm double precision,
au2_ppm double precision,
ag1_ double precision,
ag2_ double precision,
cu1_ double precision,
cu2_ double precision,
as_ double precision,
pb_ double precision,
zn_ double precision,
k2o_ double precision,
ba_ double precision,
sio2_ double precision,
al2x_ double precision,
fe2x_ double precision,
mno_ double precision,
tio2_ double precision,
p2o5_ double precision,
cao_ double precision,
mgo_ double precision,
mo_ double precision,
sn_ double precision,
sb_ double precision,
w_ double precision,
bi_ double precision,
zr_ double precision,
li_ double precision,
b_ double precision,
v_ double precision,
cr_ double precision,
ni_ double precision,
co_ double precision,
sr_ double precision,
y_ double precision,
la_ double precision,
ce_ double precision,
nb_ double precision,
be_ double precision,
cd_ double precision,
spp2 double precision,
campaign text,
datasource integer,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user
);
COMMENT ON TABLE public.surface_samples_grades IS 'Ponctual samples taken from surface: stream sediments, alluvial sediments, till, soils, termite mounds, rock outcrops, floats, etc. with grades';
COMMENT ON COLUMN public.surface_samples_grades.opid IS 'Operation identifier';
--...
COMMENT ON COLUMN public.surface_samples_grades.campaign IS 'Campaign: year, type, etc. i.e. till exploration 1967';
COMMENT ON COLUMN public.surface_samples_grades.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.surface_samples_grades.numauto IS 'Automatic integer primary key';
COMMENT ON COLUMN public.surface_samples_grades.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.surface_samples_grades.username IS 'User (role) which created data record';
-- TODO remain quite a few fields to comment. But this structure is certainly not relevant.
--}}}
--}}}
-- x geochemistry:{{{
-- x geoch_sampling:{{{
CREATE TABLE public.geoch_sampling (
opid integer
REFERENCES public.operations (opid)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED,
id text,
lab_id text,
labo_ref text,
amc_ref text, -- <= get rid of this, after dispatching information in appropriate places
reception_date date,
sample_type text,
sample_index text NOT NULL,
utm_zone text,
srid integer,
x numeric(15,4),
y numeric(15,4),
z numeric(10,4),
soil_colour text,
type_sort text,
depth_cm numeric(10,2),
reg_type text,
geomorphology text,
rock_type text,
comments text,
geologist text,
float_sampl text,
host_rock text,
prospect text,
spacing text,
horizon text,
date date, -- TODO change field name: appears highlighted in vim: obviously a reserved word
survey_type text,
grid_line text,
grid_station text,
alteration text,
occ_soil text,
slope text,
slope_dir text,
soil_description text,
datasource integer,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user
);
COMMENT ON TABLE public.geoch_sampling IS 'Geochemistry samples, from soil or stream sediments: location and description data';
COMMENT ON COLUMN public.geoch_sampling.opid IS 'Operation identifier';
COMMENT ON COLUMN public.geoch_sampling.id IS 'Identification';
COMMENT ON COLUMN public.geoch_sampling.lab_id IS 'Analysis laboratory';
COMMENT ON COLUMN public.geoch_sampling.labo_ref IS 'Analysis laboratory report reference';
COMMENT ON COLUMN public.geoch_sampling.amc_ref IS 'AMC analysis report reference'; -- TODO get AMC mentions out
COMMENT ON COLUMN public.geoch_sampling.reception_date IS 'Report reception date by AMC'; -- TODO get AMC mentions out
COMMENT ON COLUMN public.geoch_sampling.sample_type IS 'Analysis type'; -- TODO Hm. Voir.
COMMENT ON COLUMN public.geoch_sampling.sample_index IS 'Auto increment integer';
COMMENT ON COLUMN public.geoch_sampling.x IS 'X coordinate, projected in UTM (m)';
COMMENT ON COLUMN public.geoch_sampling.y IS 'Y coordinate, projected in UTM (m)';
COMMENT ON COLUMN public.geoch_sampling.z IS 'Z coordinate, projected in UTM (m)';
COMMENT ON COLUMN public.geoch_sampling.soil_colour IS 'Soil colour';
COMMENT ON COLUMN public.geoch_sampling.type_sort IS 'Sort of type';
COMMENT ON COLUMN public.geoch_sampling.depth_cm IS 'Sample depth';
COMMENT ON COLUMN public.geoch_sampling.reg_type IS 'Type of region';
COMMENT ON COLUMN public.geoch_sampling.geomorphology IS 'Some region description';
COMMENT ON COLUMN public.geoch_sampling.rock_type IS 'Lithology';
COMMENT ON COLUMN public.geoch_sampling.comments IS 'Some comments';
COMMENT ON COLUMN public.geoch_sampling.utm_zone IS 'UTM area';
COMMENT ON COLUMN public.geoch_sampling.geologist IS 'geologist';
COMMENT ON COLUMN public.geoch_sampling.float_sampl IS 'sample designation (?)';
COMMENT ON COLUMN public.geoch_sampling.host_rock IS 'host rock';
COMMENT ON COLUMN public.geoch_sampling.date IS 'type of survey (ex : HHGPS)';
COMMENT ON COLUMN public.geoch_sampling.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.geoch_sampling.numauto IS 'Automatic integer';
COMMENT ON COLUMN public.geoch_sampling.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.geoch_sampling.username IS 'User (role) which created data record';
--}}}
-- x geoch_ana:{{{
CREATE TABLE public.geoch_ana (
opid integer
REFERENCES public.operations (opid)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED,
sample_index integer,
ana_type text,
unit text,
det_lim numeric(6,4),
scheme text,
comments text,
value numeric(10,3),
datasource integer,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user
);
COMMENT ON TABLE public.geoch_ana IS 'Assay results from geochemistry samples';
COMMENT ON COLUMN public.geoch_ana.opid IS 'Operation identifier';
COMMENT ON COLUMN public.geoch_ana.sample_index IS 'Sample identification related to the geoch_sampling table';
COMMENT ON COLUMN public.geoch_ana.ana_type IS 'Analysis type ';
COMMENT ON COLUMN public.geoch_ana.unit IS 'Unit of the analysis ';
COMMENT ON COLUMN public.geoch_ana.det_lim IS 'Analysis detection limit';
COMMENT ON COLUMN public.geoch_ana.scheme IS 'Analysis method';
COMMENT ON COLUMN public.geoch_ana.comments IS 'Some comments';
COMMENT ON COLUMN public.geoch_ana.value IS 'Analysis value';
COMMENT ON COLUMN public.geoch_ana.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.geoch_ana.numauto IS 'Automatic integer primary key';
COMMENT ON COLUMN public.geoch_ana.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.geoch_ana.username IS 'User (role) which created data record';
--}}}
-- x geoch_sampling_grades:{{{
-- Vérifier si cette table est utile, et si oui en quoi, comment.
CREATE TABLE public.geoch_sampling_grades (
numauto serial PRIMARY KEY,
au_ppb numeric
)
INHERITS (geoch_sampling);
COMMENT ON TABLE public.geoch_sampling_grades IS 'Geochemistry samples with grades; table inherits from geoch_sampling';
-- COMMENT ON COLUMN public.geoch_sampling_grades.opid IS 'Operation identifier';
-- COMMENT ON COLUMN public.geoch_sampling_grades.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.geoch_sampling_grades.numauto IS 'Automatic integer primary key';
COMMENT ON COLUMN public.geoch_sampling_grades.au_ppb IS 'Au grade ppb';
--}}}
--}}}
-- x geophysics:{{{
-- x gpy_mag_ground:{{{
-- SET search_path = public, pg_catalog;
-- Name: gpy_mag_ground; Type: TABLE; Schema: public; Owner: data_admin; Tablespace:
CREATE TABLE public.gpy_mag_ground (
opid integer
REFERENCES public.operations (opid)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED,
srid integer,
x numeric,
y numeric,
z numeric,
geometry_corr geometry,
geography_4326 geography,
x_local numeric,
y_local numeric,
mag_nanotesla double precision,
val_corr_mag_nanotesla double precision,
datasource integer,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user
);
COMMENT ON TABLE public.gpy_mag_ground IS 'Geophysics: ground mag';
COMMENT ON COLUMN public.gpy_mag_ground.opid IS 'Operation identifier';
COMMENT ON COLUMN public.gpy_mag_ground.geometry_corr IS 'Manually corrected geometry: this is typically used when a GPS location turns out to be wrong, and that elements allow to better define the actual location of the survey point (field measurements, orthophoto mapping, etc.); when not NULL, this field should be used by cartographic VIEWs depending on this relation, instead of x, y fields';
COMMENT ON COLUMN public.gpy_mag_ground.geography_4326 IS 'Geographic position, in longitude-latitude according to WGS84 ellipsoid, aka EPSG 4326';
COMMENT ON COLUMN public.gpy_mag_ground.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.gpy_mag_ground.numauto IS 'Automatic integer primary key';
COMMENT ON COLUMN public.gpy_mag_ground.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.gpy_mag_ground.username IS 'User (role) which created data record';
--}}}
-- o gpy_radiometry{{{
-- TODO plans compteurs
-- }}}
-- o other methods: TODO panneau électrique, PS, sismique marteau, etc.
--}}}
-- x drill holes: table names prefixed with dh_ {{{
-- x dh_collars {{{
CREATE TABLE public.dh_collars (
opid integer
REFERENCES public.operations (opid)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED,
id text NOT NULL, -- TODO rename as dhid or dh_id and opid to be renamed op_id (once upon a time)...
location text,
campaign text,
purpose text DEFAULT 'EXPLO', -- defaulting to EXPLOration, but this is just for the time being. A preferences, or defaults, table, should be implemented; or an external file, for such default values.
profile text,
srid integer,
x numeric,
y numeric,
z numeric,
z_reference text,
geometry_corr geometry,
geography_4326 geography,
azim_ng numeric, -- TODO change for a structure with mag declination stored elsewhere
azim_nm numeric,
dip_hz numeric,
length numeric, -- TODO SQL keyword? yes...
dh_type text,
date_start date,
date_completed date,
completed boolean DEFAULT false,
contractor text,
contractor_id text,
geologist text,
nb_samples integer,
topo_survey_type text,
anomaly text,
comments text,
x_local numeric, -- TODO get rid
y_local numeric, -- TODO get rid
z_local numeric, -- TODO get rid
accusum numeric, -- TODO move to another table, one day
id_pject text,
x_pject numeric,
y_pject numeric,
z_pject numeric,
shid text,
datasource integer,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user,
UNIQUE (opid, id)
);
-- Fields from previous versions, dropped:
--len_destr numeric(10,2),
--len_pq numeric(10,2),
--len_hq numeric(10,2),
--len_nq numeric(10,2),
--len_bq numeric(10,2),
COMMENT ON TABLE public.dh_collars IS 'Drill holes collars or trenches starting points';
COMMENT ON COLUMN public.dh_collars.opid IS 'Operation identifier, refers to operations table';
COMMENT ON COLUMN public.dh_collars.id IS 'Full identifier for borehole or trench, may include zone code, type and sequential number. opid and id make the unique key of dh_collars table.';
COMMENT ON COLUMN public.dh_collars.location IS 'Investigated area code, refers to occurrences table';
COMMENT ON COLUMN public.dh_collars.campaign IS 'Campaign: year, type, etc. i.e. DDH exploration 1967';
COMMENT ON COLUMN public.dh_collars.purpose IS 'Purpose of hole: exploration, delineation, estimation, grade control, etc.';
COMMENT ON COLUMN public.dh_collars.profile IS 'Profile number';
COMMENT ON COLUMN public.dh_collars.srid IS 'Spatial Reference Identifier, or coordinate reference system: see spatial_ref_sys from postgis extension';
COMMENT ON COLUMN public.dh_collars.x IS 'X coordinate (Easting), in coordinate system srid';
COMMENT ON COLUMN public.dh_collars.y IS 'Y coordinate (Northing), in coordinate system srid';
COMMENT ON COLUMN public.dh_collars.z IS 'Z coordinate';
COMMENT ON COLUMN public.dh_collars.z_reference IS 'Altimetry (z) reference: worth mentioning, if different from srid';
COMMENT ON COLUMN public.dh_collars.geometry_corr IS 'Manually corrected geometry: this is typically used when a GPS location turns out to be wrong, and that elements allow to better define the actual location of the collar point (field measurements, orthophoto mapping, etc.); when not NULL, this field should be used by cartographic VIEWs depending on this relation, instead of x, y fields';
COMMENT ON COLUMN public.dh_collars.geography_4326 IS 'Geographic position, in longitude-latitude according to WGS84 ellipsoid, aka EPSG 4326';
COMMENT ON COLUMN public.dh_collars.azim_ng IS 'Hole or trench azimuth (°) relative to geographic North';
COMMENT ON COLUMN public.dh_collars.azim_nm IS 'Hole or trench azimuth (°) relative to Magnetic North';
COMMENT ON COLUMN public.dh_collars.dip_hz IS 'Drill hole or trench dip relative to horizontal (°)';
COMMENT ON COLUMN public.dh_collars.length IS 'Total length (m)';
COMMENT ON COLUMN public.dh_collars.dh_type IS 'Type: D for Diamond drill hole, R for RC drill hole, T for Trench, A for Auger drill hole';
COMMENT ON COLUMN public.dh_collars.date_start IS 'Work start date';
COMMENT ON COLUMN public.dh_collars.date_completed IS 'Work finish date';
COMMENT ON COLUMN public.dh_collars.completed IS 'True: completed; False: planned';
COMMENT ON COLUMN public.dh_collars.contractor IS 'Drilling contractor';
COMMENT ON COLUMN public.dh_collars.contractor_id IS 'Drilling contractor work identifier';
COMMENT ON COLUMN public.dh_collars.geologist IS 'Geologist name';
COMMENT ON COLUMN public.dh_collars.nb_samples IS 'Number of samples; mainly for quality check purpose, redundancy with count from dh_sampling child table';
COMMENT ON COLUMN public.dh_collars.topo_survey_type IS 'Topographic collar survey type: GPS, GPSD, geometry, theodolite, relative, computed from local coordinate system, etc.';
COMMENT ON COLUMN public.dh_collars.anomaly IS 'Various uses: in geotechnics, boolean for a borehole showing an anomaly, hence a special attention to be given to; in mining exploration, the name of a soil geochemistry anomaly, for instance';
COMMENT ON COLUMN public.dh_collars.comments IS 'Comments, e.g. quick history of the hole, why it stopped, remarkable facts, etc.';
COMMENT ON COLUMN public.dh_collars.x_local IS 'Local x coordinate';
COMMENT ON COLUMN public.dh_collars.y_local IS 'Local y coordinate';
COMMENT ON COLUMN public.dh_collars.z_local IS 'Local z coordinate';
COMMENT ON COLUMN public.dh_collars.accusum IS 'Accumulation sum over various mineralised intervals intersected by drill hole or trench (purpose: quick visualisation on maps (at wide scale ONLY), quick ranking of interesting holes)';
COMMENT ON COLUMN public.dh_collars.id_pject IS 'PJ for ProJect identifier: provisional identifier; aka peg number';
COMMENT ON COLUMN public.dh_collars.x_pject IS 'Planned x coordinate';
COMMENT ON COLUMN public.dh_collars.y_pject IS 'Planned y coordinate';
COMMENT ON COLUMN public.dh_collars.z_pject IS 'Planned z coordinate';
COMMENT ON COLUMN public.dh_collars.shid IS 'Short identifier: e.g. _ sequential number (rarely used)';
COMMENT ON COLUMN public.dh_collars.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.dh_collars.numauto IS 'Automatic integer primary key';
COMMENT ON COLUMN public.dh_collars.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.dh_collars.username IS 'User (role) which created data record';
--COMMENT ON COLUMN public.dh_collars.old_flid IS 'Old identifier, as in original data files'; -- field dropped
--COMMENT ON COLUMN public.collars.problems IS 'If there is a problem or not, in terms of data integrity/consistency'; -- field dropped
--COMMENT ON COLUMN public.dh_collars.export IS 'Data to be exported or not'; -- field dropped
--COMMENT ON COLUMN public.dh_collars.len_destr IS 'Destructive (percussion or rotary drilling) length (m)'; -- field dropped
--COMMENT ON COLUMN public.dh_collars.len_pq IS 'Core PQ length (m)'; -- field dropped
--COMMENT ON COLUMN public.dh_collars.len_hq IS 'Core HQ length (m)'; -- field dropped
--COMMENT ON COLUMN public.dh_collars.len_nq IS 'Core NQ length (m)'; -- field drop ped
--COMMENT ON COLUMN public.dh_collars.len_bq IS 'Core BQ length (m)'; -- field dropped
--}}}
-- _______________ENCOURS_______________GEOLLLIBRE
-- x dh_shift_reports{{{ --ATTENTION! TODO CHANGER TOUTES RÉFÉRENCES À shift_reports EN dh_shift_reports!
CREATE TABLE public.dh_shift_reports (
opid integer,
date date,
shift text,
no_fichette integer NOT NULL,
rig text,
geologist text,
time_start time with time zone,
time_end time with time zone,
id text,
peg_number text,
planned_length numeric(10,2),
tool text,
drilled_length_during_shift numeric(10,2),
drilled_length numeric(10,2),
completed boolean,
profile text,
invoice_nr integer,
drilled_shift_destr numeric,
drilled_shift_pq numeric,
drilled_shift_hq numeric,
drilled_shift_nq numeric,
recovered_length_shift numeric,
stdby_time1_h numeric,
stdby_time2_h numeric,
stdby_time3_h numeric,
moving_time_h numeric,
driller_name text,
geologist_supervisor text,
comments text,
datasource integer,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user,
FOREIGN KEY (opid, id)
REFERENCES public.dh_collars (opid, id)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED
);
COMMENT ON TABLE public.dh_shift_reports IS 'Daily reports from rigsites: one report per shift/machine/tool';
COMMENT ON COLUMN public.dh_shift_reports.opid IS 'Operation identifier';
COMMENT ON COLUMN public.dh_shift_reports.date IS 'Date of drilling';
COMMENT ON COLUMN public.dh_shift_reports.shift IS 'Day or night shift';
COMMENT ON COLUMN public.dh_shift_reports.no_fichette IS 'Number of fichette = field form filled on a shift and borehole basis';
COMMENT ON COLUMN public.dh_shift_reports.rig IS 'Name/id of drilling (or digging) machine';
COMMENT ON COLUMN public.dh_shift_reports.geologist IS 'Geologist(s) following the drill hole on the rig site, doing the logging.';
COMMENT ON COLUMN public.dh_shift_reports.time_start IS 'Drilling starting time';
COMMENT ON COLUMN public.dh_shift_reports.time_end IS 'Drilling ending time';
COMMENT ON COLUMN public.dh_shift_reports.id IS 'Drill hole identifier, must match collars.id field, e.g. UMA_R086';
COMMENT ON COLUMN public.dh_shift_reports.peg_number IS 'Peg number: provisional identifier/number; aka PJ for ProJect identifier';
COMMENT ON COLUMN public.dh_shift_reports.planned_length IS 'Length of the borehole, as initially planned';
COMMENT ON COLUMN public.dh_shift_reports.tool IS 'Drilling (digging) tool/size, diameter: RC, RAB, percussion, core, SQ, PQ, HQ, NQ, BQ, AQ, mechanical shovel, hand shovel, banka, etc.';
COMMENT ON COLUMN public.dh_shift_reports.drilled_length_during_shift IS 'Length of borehole drilled during the shift';
COMMENT ON COLUMN public.dh_shift_reports.drilled_length IS 'Total length of the borehole drilled at the end of the shift';
COMMENT ON COLUMN public.dh_shift_reports.completed IS 'Borehole finished or not';
COMMENT ON COLUMN public.dh_shift_reports.profile IS 'Section identifier';
COMMENT ON COLUMN public.dh_shift_reports.comments IS 'Comments on drilling (events, presence of water, difficulties, major facies, etc.)';
COMMENT ON COLUMN public.dh_shift_reports.invoice_nr IS 'Subcontractor invoice number';
COMMENT ON COLUMN public.dh_shift_reports.drilled_shift_destr IS 'Drilled length during shift in destructive';
COMMENT ON COLUMN public.dh_shift_reports.drilled_shift_pq IS 'Drilled length during shift in PQ core';
COMMENT ON COLUMN public.dh_shift_reports.drilled_shift_hq IS 'Drilled length during shift in HQ core';
COMMENT ON COLUMN public.dh_shift_reports.drilled_shift_nq IS 'Drilled length during shift in NQ core';
COMMENT ON COLUMN public.dh_shift_reports.recovered_length_shift IS 'Recovered length during shift';
COMMENT ON COLUMN public.dh_shift_reports.stdby_time1_h IS 'Standby time hours, with machine powered on';
COMMENT ON COLUMN public.dh_shift_reports.stdby_time2_h IS 'Standby time hours, with machine powered off';
COMMENT ON COLUMN public.dh_shift_reports.stdby_time3_h IS 'Standby time hours, due to weather conditions';
COMMENT ON COLUMN public.dh_shift_reports.moving_time_h IS 'Moving time hours';
COMMENT ON COLUMN public.dh_shift_reports.driller_name IS 'Driller supervisor name';
COMMENT ON COLUMN public.dh_shift_reports.geologist_supervisor IS 'Geologist supervisor name';
COMMENT ON COLUMN public.dh_shift_reports.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.dh_shift_reports.numauto IS 'Automatic integer';
COMMENT ON COLUMN public.dh_shift_reports.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.dh_shift_reports.username IS 'User (role) which created data record';
--}}}
-- x dh_followup {{{
CREATE TABLE public.dh_followup (
opid integer,
id text,
devia text,
quick_log text,
log_tech text,
log_litho text,
sampling text,
results text,
relogging text,
beacon text,
in_gdm text,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user,
FOREIGN KEY (opid, id)
REFERENCES public.dh_collars (opid, id)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED
);
COMMENT ON TABLE public.dh_followup IS 'Simple table for daily drill holes followup';
COMMENT ON COLUMN public.dh_followup.opid IS 'Operation identifier';
COMMENT ON COLUMN public.dh_followup.id IS 'Identifier, refers to dh_collars';
COMMENT ON COLUMN public.dh_followup.devia IS 'Deviation survey (x: done; xx: done, data entered; xxx: data verified)';
COMMENT ON COLUMN public.dh_followup.quick_log IS 'Quick geological log, typically done on hole finish, for an A4 log plot (x: done; xx: done, data entered; xxx: data verified)';
COMMENT ON COLUMN public.dh_followup.log_tech IS 'Core fitting, core measurement, meters marking, RQD, fracture counts, etc. (x: done; xx: done, data entered; xxx: data verified)';
COMMENT ON COLUMN public.dh_followup.log_litho IS 'Full geological log (x: done; xx: done, data entered; xxx: data verified)';
COMMENT ON COLUMN public.dh_followup.sampling IS 'Hole sampling (x: done; xx: done, data entered; xxx: data verified)';
COMMENT ON COLUMN public.dh_followup.results IS 'Assay results back from laboratory (x: received; xx: entered; xxx: verified)';
COMMENT ON COLUMN public.dh_followup.relogging IS 'Geological log done afterwards on mineralised intervals (x: done; xx: done, data entered; xxx: data verified)';
COMMENT ON COLUMN public.dh_followup.beacon IS 'Beacon or any other permanent hole marker on field (PVC pipe, concrete beacon, cement, etc.) (x: done)';
COMMENT ON COLUMN public.dh_followup.in_gdm IS 'Data exported to GDM; implicitely: data clean, checked by GDM procedures (x: done)';
COMMENT ON COLUMN public.dh_followup.numauto IS 'Automatic integer primary key';
COMMENT ON COLUMN public.dh_followup.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.dh_followup.username IS 'User (role) which created data record';
--}}}
-- x dh_devia {{{
CREATE TABLE public.dh_devia (
opid integer,
id text,
depto numeric(10,2),
device text,
azim_nm numeric(10,2),
azim_ng numeric(10,2),
dip_hz numeric(10,2),
x_offset numeric(10,2),
y_offset numeric(10,2),
z_offset numeric(10,2),
temperature numeric(10,2),
magnetic numeric(10,2),
date date, -- TODO change date and time fields for a timestamp value
time integer, -- TODO change field name
roll numeric(10,2),
comments text,
valid boolean DEFAULT true,
datasource integer,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user,
FOREIGN KEY (opid, id)
REFERENCES public.dh_collars (opid, id)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED
);
COMMENT ON TABLE public.dh_devia IS 'Drill holes or trenches deviations measurements';
COMMENT ON COLUMN public.dh_devia.opid IS 'Operation identifier';
COMMENT ON COLUMN public.dh_devia.id IS 'Drill hole identification related to the collars table';
COMMENT ON COLUMN public.dh_devia.depto IS 'Depth of deviation measurement';
COMMENT ON COLUMN public.dh_devia.device IS 'Device used for deviation measurement';
COMMENT ON COLUMN public.dh_devia.azim_nm IS 'Hole azimuth (°) relative to magnetic North (normally, this should be the actual measurement, with a magnetic orientation tool)';
COMMENT ON COLUMN public.dh_devia.azim_ng IS 'Hole azimuth (°) relative to geographic North';
COMMENT ON COLUMN public.dh_devia.dip_hz IS 'Drill hole dip relative to horizontal (°), positive down';
COMMENT ON COLUMN public.dh_devia.x_offset IS 'Offset of hole in x';
COMMENT ON COLUMN public.dh_devia.y_offset IS 'Offset of hole in y';
COMMENT ON COLUMN public.dh_devia.z_offset IS 'True vertical depth';
COMMENT ON COLUMN public.dh_devia.temperature IS 'temperature';
COMMENT ON COLUMN public.dh_devia.magnetic IS 'Magnetic field intensity measurement';
COMMENT ON COLUMN public.dh_devia.date IS 'Date of deviation measurement';
COMMENT ON COLUMN public.dh_devia.roll IS 'Roll angle';
COMMENT ON COLUMN public.dh_devia.time IS 'Time of deviation measurement';
COMMENT ON COLUMN public.dh_devia.comments IS 'Various comments; concerning measurements done with Reflex Gyro, all parameters are concatened as a json-like structure';
COMMENT ON COLUMN public.dh_devia.valid IS 'True when a deviation measurement is usable; queries should take into account only valid records';
COMMENT ON COLUMN public.dh_devia.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.dh_devia.numauto IS 'Automatic integer primary key';
COMMENT ON COLUMN public.dh_devia.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.dh_devia.username IS 'User (role) which created data record';
-- TODO convert the json-like data into a real json field.
--}}}
-- x dh_quicklog {{{
CREATE TABLE public.dh_quicklog (
opid integer,
id text,
depfrom numeric(10,2),
depto numeric(10,2),
code text,
description text,
oxidation text,
alteration integer,
deformation integer,
datasource integer,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user,
FOREIGN KEY (opid, id)
REFERENCES public.dh_collars (opid, id)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED
);
COMMENT ON TABLE public.dh_quicklog IS 'Quick geological log, typically done on hole finish, for an A4 log plot';
COMMENT ON COLUMN public.dh_quicklog.opid IS 'Operation identifier';
COMMENT ON COLUMN public.dh_quicklog.id IS 'Full identifier for borehole or trench';
COMMENT ON COLUMN public.dh_quicklog.depfrom IS 'Interval beginning depth';
COMMENT ON COLUMN public.dh_quicklog.depto IS 'Interval ending depth';
COMMENT ON COLUMN public.dh_quicklog.code IS 'Codification for main unit; similar to unit code in dh_litho table';
COMMENT ON COLUMN public.dh_quicklog.description IS 'Quick geological description, logging wide intervals and/or only representative portions';
COMMENT ON COLUMN public.dh_quicklog.oxidation IS 'Oxidation state: O, PO, U';
COMMENT ON COLUMN public.dh_quicklog.alteration IS 'Alteration intensity: 0: none, 1: weak, 2: moderate, 3: strong';
COMMENT ON COLUMN public.dh_quicklog.deformation IS 'Deformation intensity: 0: none, 1: weak, 2: moderate, 3: strong';
COMMENT ON COLUMN public.dh_quicklog.datasource IS 'Datasource identifier, refers to lex_datasource';
COMMENT ON COLUMN public.dh_quicklog.numauto IS 'Automatic integer primary key';
COMMENT ON COLUMN public.dh_quicklog.creation_ts IS 'Current date and time stamp when data is loaded in table';
COMMENT ON COLUMN public.dh_quicklog.username IS 'User (role) which created data record';
--}}}
-- x dh_litho {{{
-- lithological descriptions
CREATE TABLE public.dh_litho (
opid integer,
id text,
depfrom numeric(10,2),
depto numeric(10,2),
description text,
description1 text, -- TODO get rid after concatenation; or not...
description2 text, -- TODO get rid after concatenation; or not...
code1 text,
code2 text,
code3 text,
code4 text,
value1 integer,
value2 integer,
value3 integer,
value4 integer,
value5 integer,
value6 integer,
colour text,
datasource integer,
numauto serial PRIMARY KEY,
creation_ts timestamptz DEFAULT now() NOT NULL,
username text DEFAULT current_user,
UNIQUE (opid, id, depto),
FOREIGN KEY (opid, id)
REFERENCES public.dh_collars (opid, id)
ON UPDATE CASCADE
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED
);
COMMENT ON TABLE public.dh_litho IS 'Drill holes or trenches geological descriptions';
COMMENT ON COLUMN public.dh_litho.opid IS 'Operation identifier';
COMMENT ON COLUMN public.dh_litho.id IS 'Identifier, refers to dh_collars';
COMMENT ON COLUMN public.dh_litho.depfrom IS 'Interval beginning depth';
COMMENT ON COLUMN public.dh_litho.depto IS 'Interval ending depth';
COMMENT ON COLUMN public.dh_litho.description IS 'Geological description, naturalist style';
COMMENT ON COLUMN public.dh_litho.description1 IS 'Complement to main geological description: metallic minerals';
--COMMENT ON COLUMN public.dh_litho.description1 IS 'Complement1 to main geological description: metallic minerals';
COMMENT ON COLUMN dh_litho.description2 IS 'Complement to main geological description: alterations';
--COMMENT ON COLUMN public.dh_litho.description2 IS 'Complement1 to main geological description: alterations';