-
Notifications
You must be signed in to change notification settings - Fork 3
/
create_database_schema_postgres.sql
1511 lines (1347 loc) · 108 KB
/
create_database_schema_postgres.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
DROP TABLE IF EXISTS Association CASCADE;
CREATE TABLE Association (
--Identifiable Attributes
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Association'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--Association attributes
associationType VARCHAR(256) NOT NULL,
sourceObject VARCHAR(256) NOT NULL,
targetObject VARCHAR(256) NOT NULL
);
ALTER TABLE Association OWNER TO openxds;
DROP TABLE IF EXISTS AuditableEvent CASCADE;
CREATE TABLE AuditableEvent (
--Identifiable Attributes
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:AuditableEvent'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--AuditableEvent attributes
requestId VARCHAR(256) NOT NULL,
eventType VARCHAR(256) NOT NULL,
timeStamp_ VARCHAR(30) NOT NULL,
user_ VARCHAR(256) NOT NULL
);
ALTER TABLE AuditableEvent OWNER TO openxds;
DROP TABLE IF EXISTS AffectedObject CASCADE;
CREATE TABLE AffectedObject (
--Each row is a relationship between a RegistryObject and an AuditableEvent
--Enables many-to-many relationship between effected RegistryObjects and AuditableEvents
id VARCHAR(256) NOT NULL,
home VARCHAR(256),
eventId VARCHAR(256) NOT NULL,
PRIMARY KEY (id, eventId)
);
ALTER TABLE AffectedObject OWNER TO openxds;
DROP TABLE IF EXISTS repository CASCADE;
CREATE TABLE repository
(
documentuniqueid character varying(255) NOT NULL PRIMARY KEY,
mimetype character varying(255) NOT NULL,
documentsize INT NOT NULL,
hash character varying(255) NOT NULL,
"content" bytea
);
ALTER TABLE repository OWNER TO openxds;
DROP TABLE IF EXISTS personidentifier CASCADE;
CREATE TABLE personidentifier
(
registrypatientid character varying(255) NOT NULL PRIMARY KEY,
assigningauthority character varying(255) NOT NULL,
patientid character varying(255) NOT NULL,
deleted varchar(1),
merged varchar(1),
survivingpatientid character varying(255)
);
ALTER TABLE personidentifier OWNER TO openxds;
DROP TABLE IF EXISTS Classification CASCADE;
CREATE TABLE Classification (
--Identifiable Attributes
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Classification'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--Classfication attributes.
classificationNode VARCHAR(256),
classificationScheme VARCHAR(256),
classifiedObject VARCHAR(256) NOT NULL,
nodeRepresentation VARCHAR(256)
);
ALTER TABLE Classification OWNER TO openxds;
DROP TABLE IF EXISTS ClassificationNode CASCADE;
CREATE TABLE ClassificationNode (
--Identifiable Attributes
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ClassificationNode'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--ClassficationNode attributes
code VARCHAR(256),
parent VARCHAR(256),
path VARCHAR(1024)
);
ALTER TABLE ClassificationNode OWNER TO openxds;
DROP TABLE IF EXISTS ClassScheme CASCADE;
CREATE TABLE ClassScheme (
--Identifiable Attributes
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ClassificationScheme'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--ClassificationScheme attributes
isInternal VARCHAR(1) NOT NULL,
nodeType VARCHAR(256) NOT NULL
);
ALTER TABLE ClassScheme OWNER TO openxds;
DROP TABLE IF EXISTS ExternalIdentifier CASCADE;
CREATE TABLE ExternalIdentifier (
--Identifiable Attributes
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExternalIdentifier'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--ExternalIdentifier attributes
registryObject VARCHAR(256) NOT NULL,
identificationScheme VARCHAR(256) NOT NULL,
value VARCHAR(256) NOT NULL
);
ALTER TABLE ExternalIdentifier OWNER TO openxds;
DROP TABLE IF EXISTS ExternalLink CASCADE;
CREATE TABLE ExternalLink (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--ExternalLink attributes
externalURI VARCHAR(256) NOT NULL
);
ALTER TABLE ExternalLink OWNER TO openxds;
DROP TABLE IF EXISTS ExtrinsicObject CASCADE;
CREATE TABLE ExtrinsicObject (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--ExtrinsicObject attributes
isOpaque VARCHAR(1) NOT NULL,
mimeType VARCHAR(256),
--contentVersionInfo flattened
contentVersionName VARCHAR(16),
contentVersionComment VARCHAR(256)
);
ALTER TABLE ExtrinsicObject OWNER TO openxds;
DROP TABLE IF EXISTS Federation CASCADE;
CREATE TABLE Federation (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Federation'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--Federation attributes: currently none defined
--xsd:duration stored in string form since no corresponding SQL type. Is 32 long enough?
replicationSyncLatency VARCHAR(32)
);
ALTER TABLE Federation OWNER TO openxds;
DROP TABLE IF EXISTS Name_ CASCADE;
CREATE TABLE Name_ (
--LocalizedString attributes flattened for Name
charset VARCHAR(32),
lang VARCHAR(32) NOT NULL,
value VARCHAR(1024) NOT NULL,
--The RegistryObject id for the parent RegistryObject for which this is a Name
parent VARCHAR(256) NOT NULL,
PRIMARY KEY (parent, lang)
);
ALTER TABLE Name_ OWNER TO openxds;
DROP TABLE IF EXISTS Description CASCADE;
CREATE TABLE Description (
--LocalizedString attributes flattened for Description
charset VARCHAR(32),
lang VARCHAR(32) NOT NULL,
value VARCHAR(1024) NOT NULL,
--The RegistryObject id for the parent RegistryObject for which this is a Name
parent VARCHAR(256) NOT NULL,
PRIMARY KEY (parent, lang)
);
ALTER TABLE Description OWNER TO openxds;
DROP TABLE IF EXISTS UsageDescription CASCADE;
CREATE TABLE UsageDescription (
--LocalizedString attributes flattened for UsageDescription
charset VARCHAR(32),
lang VARCHAR(32) NOT NULL,
value VARCHAR(1024) NOT NULL,
--The RegistryObject id for the parent RegistryObject for which this is a Name
parent VARCHAR(256) NOT NULL,
PRIMARY KEY (parent, lang)
);
ALTER TABLE UsageDescription OWNER TO openxds;
DROP TABLE IF EXISTS ObjectRef CASCADE;
CREATE TABLE ObjectRef (
--Stores remote ObjectRefs only
--Identifiable Attributes
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256)
);
ALTER TABLE ObjectRef OWNER TO openxds;
DROP TABLE IF EXISTS Organization CASCADE;
CREATE TABLE Organization (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Organization'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--Organization attributes
--Organization.address attribute is in PostalAddress table
parent VARCHAR(256),
--primary contact for Organization, points to a User.
primaryContact VARCHAR(256)
--Organization.telephoneNumbers attribute is in TelephoneNumber table
);
ALTER TABLE Organization OWNER TO openxds;
DROP TABLE IF EXISTS RegistryPackage CASCADE;
CREATE TABLE RegistryPackage (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:RegistryPackage'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256)
--RegistryPackage attributes: currently none defined
);
ALTER TABLE RegistryPackage OWNER TO openxds;
DROP TABLE IF EXISTS PostalAddress CASCADE;
CREATE TABLE PostalAddress (
city VARCHAR(64),
country VARCHAR(64),
postalCode VARCHAR(64),
state VARCHAR(64),
street VARCHAR(64),
streetNumber VARCHAR(32),
--The parent object that this is an address for
parent VARCHAR(256) NOT NULL
);
ALTER TABLE PostalAddress OWNER TO openxds;
DROP TABLE IF EXISTS EmailAddress CASCADE;
CREATE TABLE EmailAddress (
address VARCHAR(64) NOT NULL,
type VARCHAR(256),
--The parent object that this is an email address for
parent VARCHAR(256) NOT NULL
);
ALTER TABLE EmailAddress OWNER TO openxds;
DROP TABLE IF EXISTS Registry CASCADE;
CREATE TABLE Registry (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Registry'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--Registry attributes
--xsd:duration stored in string form since no corresponding SQL type. Is 32 long enough?
catalogingSyncLatency VARCHAR(32) DEFAULT 'P1D',
conformanceProfile VARCHAR(16),
operator VARCHAR(256) NOT NULL,
--xsd:duration stored in string form since no corresponding SQL type. Is 32 long enough?
replicationSyncLatency VARCHAR(32) DEFAULT 'P1D',
specificationVersion VARCHAR(8) NOT NULL
);
ALTER TABLE Registry OWNER TO openxds;
DROP TABLE IF EXISTS Service CASCADE;
CREATE TABLE Service (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Service'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256)
--Service attributes: currently none defined
);
ALTER TABLE Service OWNER TO openxds;
DROP TABLE IF EXISTS ServiceBinding CASCADE;
CREATE TABLE ServiceBinding (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ServiceBinding'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--ServiceBinding attributes
service VARCHAR(256) NOT NULL,
accessURI VARCHAR(256),
targetBinding VARCHAR(256)
);
ALTER TABLE ServiceBinding OWNER TO openxds;
DROP TABLE IF EXISTS Slot CASCADE;
CREATE TABLE Slot (
--Multiple rows of Slot make up a single Slot
sequenceId INT NOT NULL,
name_ VARCHAR(256) NOT NULL,
slotType VARCHAR(256),
value VARCHAR(256),
--The parent RegistryObject that this is a Slot for
parent VARCHAR(256) NOT NULL,
PRIMARY KEY (parent, name_, sequenceId)
);
ALTER TABLE Slot OWNER TO openxds;
DROP TABLE IF EXISTS SpecificationLink CASCADE;
CREATE TABLE SpecificationLink (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:SpecificationLink'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--SpecificationLink attributes
serviceBinding VARCHAR(256) NOT NULL,
specificationObject VARCHAR(256) NOT NULL
);
ALTER TABLE SpecificationLink OWNER TO openxds;
DROP TABLE IF EXISTS Subscription CASCADE;
CREATE TABLE Subscription (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Subscription'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--Subscription attributes
selector VARCHAR(256) NOT NULL,
endTime VARCHAR(30),
--xsd:duration stored in string form since no corresponding SQL type. Is 32 long enough?
notificationInterval VARCHAR(32) DEFAULT 'P1D',
startTime VARCHAR(30)
);
ALTER TABLE Subscription OWNER TO openxds;
DROP TABLE IF EXISTS NotifyAction CASCADE;
CREATE TABLE NotifyAction (
notificationOption VARCHAR(256) NOT NULL,
--Either a ref to a Service, a String representing an email address in form: mailto:user@server,
--or a String representing an http URLin form: http://url
endPoint VARCHAR(256) NOT NULL,
--Parent Subscription reference
parent VARCHAR(256) NOT NULL
);
ALTER TABLE NotifyAction OWNER TO openxds;
DROP TABLE IF EXISTS Notification CASCADE;
CREATE TABLE Notification (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Notification'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--Notification attributes
subscription VARCHAR(256) NOT NULL
);
ALTER TABLE Notification OWNER TO openxds;
DROP TABLE IF EXISTS NotificationObject CASCADE;
CREATE TABLE NotificationObject (
--Each row is a relationship between a RegistryObject and a Notification
--Enables a Notification to have multiple RegistryObjects
notificationId VARCHAR(256) NOT NULL,
registryObjectId VARCHAR(256) NOT NULL,
PRIMARY KEY (notificationId, registryObjectId)
);
ALTER TABLE NotificationObject OWNER TO openxds;
DROP TABLE IF EXISTS AdhocQuery CASCADE;
CREATE TABLE AdhocQuery (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:AdhocQuery'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--AdhocQuery attributes. Flattend QueryExpression attributes
queryLanguage VARCHAR(256) NOT NULL,
query VARCHAR(4096) NOT NULL
);
ALTER TABLE AdhocQuery OWNER TO openxds;
DROP TABLE IF EXISTS UsageParameter CASCADE;
CREATE TABLE UsageParameter (
value VARCHAR(1024) NOT NULL,
--The parent SpecificationLink that this is a usage parameter for
parent VARCHAR(256) NOT NULL
);
ALTER TABLE UsageParameter OWNER TO openxds;
DROP TABLE IF EXISTS TelephoneNumber CASCADE;
CREATE TABLE TelephoneNumber (
areaCode VARCHAR(8),
countryCode VARCHAR(8),
extension VARCHAR(8),
-- we use "number_" instead of number, which is reserved in Oracle
number_ VARCHAR(16),
phoneType VARCHAR(256),
parent VARCHAR(256) NOT NULL
);
ALTER TABLE TelephoneNumber OWNER TO openxds;
DROP TABLE IF EXISTS User_ CASCADE;
CREATE TABLE User_ (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Person:User'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--User attributes
--address is in PostalAddress table
--email is in EMailAddress table
--personName flattened
personName_firstName VARCHAR(64),
personName_middleName VARCHAR(64),
personName_lastName VARCHAR(64)
--telephoneNumbers is in TelephoneNumber table
);
ALTER TABLE User_ OWNER TO openxds;
DROP TABLE IF EXISTS Person CASCADE;
CREATE TABLE Person (
id VARCHAR(256) NOT NULL PRIMARY KEY,
home VARCHAR(256),
--RegistryObject Attributes
lid VARCHAR(256) NOT NULL,
objectType VARCHAR(256) CHECK (objectType = 'urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Person'),
status VARCHAR(256) NOT NULL,
--VersionInfo flattened
versionName VARCHAR(16),
comment_ VARCHAR(256),
--User attributes
--address is in PostalAddress table
--email is in EMailAddress table
--personName flattened
personName_firstName VARCHAR(64),
personName_middleName VARCHAR(64),
personName_lastName VARCHAR(64)
--telephoneNumbers is in TelephoneNumber table
);
ALTER TABLE Person OWNER TO openxds;
DROP TABLE IF EXISTS RepositoryItem CASCADE;
CREATE TABLE RepositoryItem
(
lid character varying(256) NOT NULL,
versionname character varying(16) NOT NULL,
"content" bytea,
PRIMARY KEY(lid, versionname)
);
ALTER TABLE RepositoryItem OWNER TO openxds;
DROP VIEW IF EXISTS Identifiable CASCADE;
CREATE VIEW Identifiable (
--Identifiable Attributes
id,
home
) AS
SELECT
--Identifiable Attributes
id,
home
FROM AdhocQuery
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM Association
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM AuditableEvent
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM Classification
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM ClassificationNode
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM ClassScheme
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM ExternalIdentifier
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM ExternalLink
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM ExtrinsicObject
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM Federation
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM Organization
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM Registry
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM RegistryPackage
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM Service
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM ServiceBinding
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM SpecificationLink
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM Subscription
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM User_
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM Person
UNION ALL
SELECT
--Identifiable Attributes
id,
home
FROM ObjectRef
;
ALTER TABLE Identifiable OWNER TO openxds;
DROP VIEW IF EXISTS RegistryObject CASCADE;
CREATE VIEW RegistryObject (
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
) AS
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM AdhocQuery
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM Association
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM AuditableEvent
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM Classification
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM ClassificationNode
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM ClassScheme
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM ExternalIdentifier
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM ExternalLink
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM ExtrinsicObject
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM Federation
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM Organization
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM Registry
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM RegistryPackage
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM Service
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM ServiceBinding
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM SpecificationLink
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM Subscription
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM User_
UNION ALL
SELECT
--Identifiable Attributes
id,
home,
--RegistryObject Attributes
lid,
objectType,
status,
--VersionInfo flattened
versionName,
comment_
FROM Person
;
ALTER TABLE RegistryObject OWNER TO openxds;
--All index definitions are non-normative
---
-- FOR ORACLE, YOU MUST COMMMENT ALL THE FOLLOWING LINES BECAUSE ORACLE DOES
-- NOT ALLOW CREATE INDEX ON PRIMARY KEYS
--
--lid index
DROP INDEX IF EXISTS lid_AdhQuery_idx;
DROP INDEX IF EXISTS lid_Assoc_idx;
DROP INDEX IF EXISTS lid_AUEVENT_idx;
DROP INDEX IF EXISTS lid_Class_idx;
DROP INDEX IF EXISTS lid_Node_idx;
DROP INDEX IF EXISTS lid_SCHEME_idx;
DROP INDEX IF EXISTS lid_EID_idx;
DROP INDEX IF EXISTS lid_ExLink_idx;
DROP INDEX IF EXISTS lid_EXTOBJ_idx;
DROP INDEX IF EXISTS lid_FED_idx;
DROP INDEX IF EXISTS lid_ORG_idx;
DROP INDEX IF EXISTS lid_Registry_idx;
DROP INDEX IF EXISTS lid_PKG_idx;