Project

General

Profile

Bug #696 » NewRef_3.sql

Michael Lee, 01/07/2003 11:56 AM

 
1
-----CREATE TABLES----------
2
CREATE TABLE citation
3
(
4
  citation_ID serial NOT NULL,
5
  shortName varchar (250) ,
6
  citationType varchar (250) ,
7
  title varchar (250) ,
8
  titleSuperior varchar (250) ,
9
  pubDate Date ,
10
  accessDate Date ,
11
  conferenceDate Date ,
12
  citationJournal_ID INTEGER ,
13
  volume varchar (250) ,
14
  issue varchar (250) ,
15
  pageRange varchar (250) ,
16
  totalPages INTEGER ,
17
  publisher varchar (250) ,
18
  publicationPlace varchar (250) ,
19
  isbn varchar (250) ,
20
  edition varchar (250) ,
21
  numberOfVolumes INTEGER ,
22
  chapterNumber INTEGER ,
23
  reportNumber INTEGER ,
24
  communicationType varchar (250) ,
25
  degree varchar (250) ,
26
  url varchar (250) ,
27
  doi varchar (250) ,
28
  additionalInfo varchar (250) ,
29
  comments text ,
30
  PRIMARY KEY(citation_ID)
31
);
32
CREATE TABLE citationAlternateIdentifier
33
(
34
  citationAlternateIdentifier_ID serial NOT NULL,
35
  system varchar (250) ,
36
  identifier varchar (250) NOT NULL,
37
  PRIMARY KEY(citationAlternateIdentifier_ID)
38
);
39
CREATE TABLE citationContributor
40
(
41
  citationContributor_ID serial NOT NULL,
42
  citation_ID INTEGER NOT NULL,
43
  citationParty_ID INTEGER NOT NULL,
44
  roleType varchar (250) ,
45
  order INTEGER ,
46
  PRIMARY KEY(citationContributor_ID)
47
);
48
CREATE TABLE citationParty
49
(
50
  citationParty_ID serial NOT NULL,
51
  type varchar (250) ,
52
  positionName varchar (250) ,
53
  salutation varchar (250) ,
54
  givenName varchar (250) ,
55
  surname varchar (250) ,
56
  suffix varchar (250) ,
57
  organizationName varchar (250) ,
58
  currentParty INTEGER ,
59
  PRIMARY KEY(citationParty_ID)
60
);
61
CREATE TABLE citationJournal
62
(
63
  citationJournal_ID serial NOT NULL,
64
  journal varchar (250) NOT NULL,
65
  issn varchar (250) ,
66
  abbreviation varchar (250) ,
67
  PRIMARY KEY(citationJournal_ID)
68
);
69
CREATE TABLE commReference
70
(
71
  commReference_ID serial NOT NULL,
72
  shortName varchar (250) ,
73
  citationType varchar (250) ,
74
  title varchar (250) ,
75
  titleSuperior varchar (250) ,
76
  pubDate Date ,
77
  accessDate Date ,
78
  conferenceDate Date ,
79
  commReferenceJournal_ID INTEGER ,
80
  volume varchar (250) ,
81
  issue varchar (250) ,
82
  pageRange varchar (250) ,
83
  totalPages INTEGER ,
84
  publisher varchar (250) ,
85
  publicationPlace varchar (250) ,
86
  isbn varchar (250) ,
87
  edition varchar (250) ,
88
  numberOfVolumes INTEGER ,
89
  chapterNumber INTEGER ,
90
  reportNumber INTEGER ,
91
  communicationType varchar (250) ,
92
  degree varchar (250) ,
93
  url varchar (250) ,
94
  doi varchar (250) ,
95
  additionalInfo varchar (250) ,
96
  comments text ,
97
  PRIMARY KEY(commReference_ID)
98
);
99
CREATE TABLE commReferenceAlternateIdentifier
100
(
101
  commReferenceAlternateIdentifier_ID serial NOT NULL,
102
  system varchar (250) ,
103
  identifier varchar (250) NOT NULL,
104
  PRIMARY KEY(commReferenceAlternateIdentifier_ID)
105
);
106
CREATE TABLE commReferenceContributor
107
(
108
  commReferenceContributor_ID serial NOT NULL,
109
  commReference_ID INTEGER NOT NULL,
110
  commReferenceParty_ID INTEGER NOT NULL,
111
  roleType varchar (250) ,
112
  order INTEGER ,
113
  PRIMARY KEY(commReferenceContributor_ID)
114
);
115
CREATE TABLE commReferenceParty
116
(
117
  commReferenceParty_ID serial NOT NULL,
118
  type varchar (250) ,
119
  positionName varchar (250) ,
120
  salutation varchar (250) ,
121
  givenName varchar (250) ,
122
  surname varchar (250) ,
123
  suffix varchar (250) ,
124
  organizationName varchar (250) ,
125
  currentParty INTEGER ,
126
  PRIMARY KEY(commReferenceParty_ID)
127
);
128
CREATE TABLE commReferenceJournal
129
(
130
  commReferenceJournal_ID serial NOT NULL,
131
  journal varchar (250) NOT NULL,
132
  issn varchar (250) ,
133
  abbreviation varchar (250) ,
134
  PRIMARY KEY(commReferenceJournal_ID)
135
);
136
CREATE TABLE plantReference
137
(
138
  plantReference_ID serial NOT NULL,
139
  shortName varchar (250) ,
140
  citationType varchar (250) ,
141
  title varchar (250) ,
142
  titleSuperior varchar (250) ,
143
  pubDate Date ,
144
  accessDate Date ,
145
  conferenceDate Date ,
146
  plantReferenceJournal_ID INTEGER ,
147
  volume varchar (250) ,
148
  issue varchar (250) ,
149
  pageRange varchar (250) ,
150
  totalPages INTEGER ,
151
  publisher varchar (250) ,
152
  publicationPlace varchar (250) ,
153
  isbn varchar (250) ,
154
  edition varchar (250) ,
155
  numberOfVolumes INTEGER ,
156
  chapterNumber INTEGER ,
157
  reportNumber INTEGER ,
158
  communicationType varchar (250) ,
159
  degree varchar (250) ,
160
  url varchar (250) ,
161
  doi varchar (250) ,
162
  additionalInfo varchar (250) ,
163
  comments text ,
164
  PRIMARY KEY(plantReference_ID)
165
);
166
CREATE TABLE plantReferenceAlternateIdentifier
167
(
168
  plantReferenceAlternateIdentifier_ID serial NOT NULL,
169
  system varchar (250) ,
170
  identifier varchar (250) NOT NULL,
171
  PRIMARY KEY(plantReferenceAlternateIdentifier_ID)
172
);
173
CREATE TABLE plantReferenceContributor
174
(
175
  plantReferenceContributor_ID serial NOT NULL,
176
  plantReference_ID INTEGER NOT NULL,
177
  plantReferenceParty_ID INTEGER NOT NULL,
178
  roleType varchar (250) ,
179
  order INTEGER ,
180
  PRIMARY KEY(plantReferenceContributor_ID)
181
);
182
CREATE TABLE plantReferenceParty
183
(
184
  plantReferenceParty_ID serial NOT NULL,
185
  type varchar (250) ,
186
  positionName varchar (250) ,
187
  salutation varchar (250) ,
188
  givenName varchar (250) ,
189
  surname varchar (250) ,
190
  suffix varchar (250) ,
191
  organizationName varchar (250) ,
192
  currentParty INTEGER ,
193
  PRIMARY KEY(plantReferenceParty_ID)
194
);
195
CREATE TABLE plantReferenceJournal
196
(
197
  plantReferenceJournal_ID serial NOT NULL,
198
  journal varchar (250) NOT NULL,
199
  issn varchar (250) ,
200
  abbreviation varchar (250) ,
201
  PRIMARY KEY(plantReferenceJournal_ID)
202
);
203
---------CREATE RELATIONSHIPS-----------------
204
ALTER TABLE citation
205
  ADD CONSTRAINT Rel_1_citationJournal_ID FOREIGN KEY (citationJournal_ID)
206
  REFERENCES citationJournal (citationJournal_ID);
207
ALTER TABLE citationContributor
208
  ADD CONSTRAINT Rel_2_citation_ID FOREIGN KEY (citation_ID)
209
  REFERENCES citation (citation_ID);
210
ALTER TABLE citationContributor
211
  ADD CONSTRAINT Rel_3_citationParty_ID FOREIGN KEY (citationParty_ID)
212
  REFERENCES citationParty (citationParty_ID);
213
ALTER TABLE citationParty
214
  ADD CONSTRAINT Rel_4_currentParty FOREIGN KEY (currentParty)
215
  REFERENCES citationParty (citationParty_ID);
216
ALTER TABLE commReference
217
  ADD CONSTRAINT Rel_5_commReferenceJournal_ID FOREIGN KEY (commReferenceJournal_ID)
218
  REFERENCES commReferenceJournal (commReferenceJournal_ID);
219
ALTER TABLE commReferenceContributor
220
  ADD CONSTRAINT Rel_6_commReference_ID FOREIGN KEY (commReference_ID)
221
  REFERENCES commReference (commReference_ID);
222
ALTER TABLE commReferenceContributor
223
  ADD CONSTRAINT Rel_7_commReferenceParty_ID FOREIGN KEY (commReferenceParty_ID)
224
  REFERENCES commReferenceParty (commReferenceParty_ID);
225
ALTER TABLE commReferenceParty
226
  ADD CONSTRAINT Rel_8_currentParty FOREIGN KEY (currentParty)
227
  REFERENCES commReferenceParty (commReferenceParty_ID);
228
ALTER TABLE plantReference
229
  ADD CONSTRAINT Rel_9_plantReferenceJournal_ID FOREIGN KEY (plantReferenceJournal_ID)
230
  REFERENCES plantReferenceJournal (plantReferenceJournal_ID);
231
ALTER TABLE plantReferenceContributor
232
  ADD CONSTRAINT Rel_10_plantReference_ID FOREIGN KEY (plantReference_ID)
233
  REFERENCES plantReference (plantReference_ID);
234
ALTER TABLE plantReferenceContributor
235
  ADD CONSTRAINT Rel_11_plantReferenceParty_ID FOREIGN KEY (plantReferenceParty_ID)
236
  REFERENCES plantReferenceParty (plantReferenceParty_ID);
237
ALTER TABLE plantReferenceParty
238
  ADD CONSTRAINT Rel_12_currentParty FOREIGN KEY (currentParty)
239
  REFERENCES plantReferenceParty (plantReferenceParty_ID);
240
---------CREATE CLOSED LIST TABLES and relationships---------
241
CREATE TABLE aux_citation_citationType
242
(
243
  [values] varchar (255) not null,
244
  SortOrd integer,
245
  PRIMARY KEY([values])
246
);
247
     -- insert values--
248
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'Article',1;
249
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'Book',2;
250
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'Chapter',3;
251
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'EditedBook',4;
252
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'Manuscript',5;
253
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'Report',6;
254
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'Thesis',7;
255
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'ConferenceProceedings',8;
256
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'PersonalCommunication',9;
257
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'Presentation',10;
258
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'Website',11;
259
INSERT INTO aux_citation_citationType ([values],SortOrd) SELECT 'Generic',12;
260
    -- add relationship for closed list --
261
ALTER TABLE citation
262
  ADD CONSTRAINT Rel_13_citationType FOREIGN KEY (citationType)
263
  REFERENCES aux_citation_citationType ([values]);
264
CREATE TABLE aux_citation_titleSuperior
265
(
266
  [values] varchar (255) not null,
267
  SortOrd integer,
268
  PRIMARY KEY([values])
269
);
270
     -- insert values--
271
INSERT INTO aux_citation_titleSuperior ([values],SortOrd) SELECT 'ConferenceName',1;
272
INSERT INTO aux_citation_titleSuperior ([values],SortOrd) SELECT 'BookTitle',2;
273
    -- add relationship for closed list --
274
ALTER TABLE citation
275
  ADD CONSTRAINT Rel_14_titleSuperior FOREIGN KEY (titleSuperior)
276
  REFERENCES aux_citation_titleSuperior ([values]);
277
CREATE TABLE aux_citationContributor_roleType
278
(
279
  [values] varchar (255) not null,
280
  SortOrd integer,
281
  PRIMARY KEY([values])
282
);
283
     -- insert values--
284
INSERT INTO aux_citationContributor_roleType ([values],SortOrd) SELECT 'Author',1;
285
INSERT INTO aux_citationContributor_roleType ([values],SortOrd) SELECT 'Editor',2;
286
INSERT INTO aux_citationContributor_roleType ([values],SortOrd) SELECT 'Originator',3;
287
INSERT INTO aux_citationContributor_roleType ([values],SortOrd) SELECT 'Performer',4;
288
INSERT INTO aux_citationContributor_roleType ([values],SortOrd) SELECT 'Recipient',5;
289
INSERT INTO aux_citationContributor_roleType ([values],SortOrd) SELECT 'CustodianSteward',6;
290
    -- add relationship for closed list --
291
ALTER TABLE citationContributor
292
  ADD CONSTRAINT Rel_15_roleType FOREIGN KEY (roleType)
293
  REFERENCES aux_citationContributor_roleType ([values]);
294
CREATE TABLE aux_commReference_citationType
295
(
296
  [values] varchar (255) not null,
297
  SortOrd integer,
298
  PRIMARY KEY([values])
299
);
300
     -- insert values--
301
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'Article',1;
302
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'Book',2;
303
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'Chapter',3;
304
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'EditedBook',4;
305
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'Manuscript',5;
306
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'Report',6;
307
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'Thesis',7;
308
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'ConferenceProceedings',8;
309
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'PersonalCommunication',9;
310
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'Presentation',10;
311
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'Website',11;
312
INSERT INTO aux_commReference_citationType ([values],SortOrd) SELECT 'Generic',12;
313
    -- add relationship for closed list --
314
ALTER TABLE commReference
315
  ADD CONSTRAINT Rel_16_citationType FOREIGN KEY (citationType)
316
  REFERENCES aux_commReference_citationType ([values]);
317
CREATE TABLE aux_commReference_titleSuperior
318
(
319
  [values] varchar (255) not null,
320
  SortOrd integer,
321
  PRIMARY KEY([values])
322
);
323
     -- insert values--
324
INSERT INTO aux_commReference_titleSuperior ([values],SortOrd) SELECT 'ConferenceName',1;
325
INSERT INTO aux_commReference_titleSuperior ([values],SortOrd) SELECT 'BookTitle',2;
326
    -- add relationship for closed list --
327
ALTER TABLE commReference
328
  ADD CONSTRAINT Rel_17_titleSuperior FOREIGN KEY (titleSuperior)
329
  REFERENCES aux_commReference_titleSuperior ([values]);
330
CREATE TABLE aux_commReferenceContributor_roleType
331
(
332
  [values] varchar (255) not null,
333
  SortOrd integer,
334
  PRIMARY KEY([values])
335
);
336
     -- insert values--
337
INSERT INTO aux_commReferenceContributor_roleType ([values],SortOrd) SELECT 'Author',1;
338
INSERT INTO aux_commReferenceContributor_roleType ([values],SortOrd) SELECT 'Editor',2;
339
INSERT INTO aux_commReferenceContributor_roleType ([values],SortOrd) SELECT 'Originator',3;
340
INSERT INTO aux_commReferenceContributor_roleType ([values],SortOrd) SELECT 'Performer',4;
341
INSERT INTO aux_commReferenceContributor_roleType ([values],SortOrd) SELECT 'Recipient',5;
342
INSERT INTO aux_commReferenceContributor_roleType ([values],SortOrd) SELECT 'CustodianSteward',6;
343
    -- add relationship for closed list --
344
ALTER TABLE commReferenceContributor
345
  ADD CONSTRAINT Rel_18_roleType FOREIGN KEY (roleType)
346
  REFERENCES aux_commReferenceContributor_roleType ([values]);
347
CREATE TABLE aux_plantReference_citationType
348
(
349
  [values] varchar (255) not null,
350
  SortOrd integer,
351
  PRIMARY KEY([values])
352
);
353
     -- insert values--
354
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'Article',1;
355
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'Book',2;
356
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'Chapter',3;
357
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'EditedBook',4;
358
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'Manuscript',5;
359
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'Report',6;
360
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'Thesis',7;
361
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'ConferenceProceedings',8;
362
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'PersonalCommunication',9;
363
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'Presentation',10;
364
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'Website',11;
365
INSERT INTO aux_plantReference_citationType ([values],SortOrd) SELECT 'Generic',12;
366
    -- add relationship for closed list --
367
ALTER TABLE plantReference
368
  ADD CONSTRAINT Rel_19_citationType FOREIGN KEY (citationType)
369
  REFERENCES aux_plantReference_citationType ([values]);
370
CREATE TABLE aux_plantReference_titleSuperior
371
(
372
  [values] varchar (255) not null,
373
  SortOrd integer,
374
  PRIMARY KEY([values])
375
);
376
     -- insert values--
377
INSERT INTO aux_plantReference_titleSuperior ([values],SortOrd) SELECT 'ConferenceName',1;
378
INSERT INTO aux_plantReference_titleSuperior ([values],SortOrd) SELECT 'BookTitle',2;
379
    -- add relationship for closed list --
380
ALTER TABLE plantReference
381
  ADD CONSTRAINT Rel_20_titleSuperior FOREIGN KEY (titleSuperior)
382
  REFERENCES aux_plantReference_titleSuperior ([values]);
383
CREATE TABLE aux_plantReferenceContributor_roleType
384
(
385
  [values] varchar (255) not null,
386
  SortOrd integer,
387
  PRIMARY KEY([values])
388
);
389
     -- insert values--
390
INSERT INTO aux_plantReferenceContributor_roleType ([values],SortOrd) SELECT 'Author',1;
391
INSERT INTO aux_plantReferenceContributor_roleType ([values],SortOrd) SELECT 'Editor',2;
392
INSERT INTO aux_plantReferenceContributor_roleType ([values],SortOrd) SELECT 'Originator',3;
393
INSERT INTO aux_plantReferenceContributor_roleType ([values],SortOrd) SELECT 'Performer',4;
394
INSERT INTO aux_plantReferenceContributor_roleType ([values],SortOrd) SELECT 'Recipient',5;
395
INSERT INTO aux_plantReferenceContributor_roleType ([values],SortOrd) SELECT 'CustodianSteward',6;
396
    -- add relationship for closed list --
397
ALTER TABLE plantReferenceContributor
398
  ADD CONSTRAINT Rel_21_roleType FOREIGN KEY (roleType)
399
  REFERENCES aux_plantReferenceContributor_roleType ([values]);
(2-2/6)