default_schema-1.11-1.2-diff.sql 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. create table cvprop (
  2. cvprop_id serial not null,
  3. primary key (cvprop_id),
  4. cv_id int not null,
  5. foreign key (cv_id) references cv (cv_id) INITIALLY DEFERRED,
  6. type_id int not null,
  7. foreign key (type_id) references cvterm (cvterm_id) INITIALLY DEFERRED,
  8. value text,
  9. rank int not null default 0,
  10. constraint cvprop_c1 unique (cv_id,type_id,rank)
  11. );
  12. COMMENT ON TABLE cvprop IS 'Additional extensible properties can be attached to a cv using this table. A notable example would be the cv version';
  13. COMMENT ON COLUMN cvprop.type_id IS 'The name of the property or slot is a cvterm. The meaning of the property is defined in that cvterm.';
  14. COMMENT ON COLUMN cvprop.value IS 'The value of the property, represented as text. Numeric values are converted to their text representation.';
  15. COMMENT ON COLUMN cvprop.rank IS 'Property-Value ordering. Any
  16. cv can have multiple values for any particular property type -
  17. these are ordered in a list using rank, counting from zero. For
  18. properties that are single-valued rather than multi-valued, the
  19. default 0 value should be used.';
  20. create table chadoprop (
  21. chadoprop_id serial not null,
  22. primary key (chadoprop_id),
  23. type_id int not null,
  24. foreign key (type_id) references cvterm (cvterm_id) INITIALLY DEFERRED,
  25. value text,
  26. rank int not null default 0,
  27. constraint chadoprop_c1 unique (type_id,rank)
  28. );
  29. COMMENT ON TABLE chadoprop IS 'This table is different from other prop tables in the database, as it is for storing information about the database itself, like schema version';
  30. COMMENT ON COLUMN chadoprop.type_id IS 'The name of the property or slot is a cvterm. The meaning of the property is defined in that cvterm.';
  31. COMMENT ON COLUMN chadoprop.value IS 'The value of the property, represented as text. Numeric values are converted to their text representation.';
  32. COMMENT ON COLUMN chadoprop.rank IS 'Property-Value ordering. Any
  33. cv can have multiple values for any particular property type -
  34. these are ordered in a list using rank, counting from zero. For
  35. properties that are single-valued rather than multi-valued, the
  36. default 0 value should be used.';
  37. ALTER TABLE genetic_code.gencode_startcodon ADD CONSTRAINT gencode_startcodon_unique UNIQUE( gencode_id, codon );
  38. ALTER TABLE phenotype ADD COLUMN name TEXT default null;
  39. ALTER TABLE genotype ADD COLUMN type_id INT NOT NULL;
  40. ALTER TABLE genotype ADD CONSTRAINT genotype_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm (cvterm_id) ON DELETE CASCADE;
  41. create table genotypeprop (
  42. genotypeprop_id serial not null,
  43. primary key (genotypeprop_id),
  44. genotype_id int not null,
  45. foreign key (genotype_id) references genotype (genotype_id) on delete cascade INITIALLY DEFERRED,
  46. type_id int not null,
  47. foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
  48. value text null,
  49. rank int not null default 0,
  50. constraint genotypeprop_c1 unique (genotype_id,type_id,rank)
  51. );
  52. create index genotypeprop_idx1 on genotypeprop (genotype_id);
  53. create index genotypeprop_idx2 on genotypeprop (type_id);
  54. CREATE TABLE projectprop (
  55. projectprop_id serial NOT NULL,
  56. PRIMARY KEY (projectprop_id),
  57. project_id integer NOT NULL,
  58. FOREIGN KEY (project_id) REFERENCES project (project_id) ON DELETE CASCADE,
  59. type_id integer NOT NULL,
  60. FOREIGN KEY (type_id) REFERENCES cvterm (cvterm_id) ON DELETE CASCADE,
  61. value text,
  62. rank integer not null default 0,
  63. CONSTRAINT projectprop_c1 UNIQUE (project_id, type_id, rank)
  64. );
  65. -- ================================================
  66. -- TABLE: project_relationship
  67. -- ================================================
  68. CREATE TABLE project_relationship (
  69. project_relationship_id serial NOT NULL,
  70. PRIMARY KEY (project_relationship_id),
  71. subject_project_id integer NOT NULL,
  72. FOREIGN KEY (subject_project_id) REFERENCES project (project_id) ON DELETE CASCADE,
  73. object_project_id integer NOT NULL,
  74. FOREIGN KEY (object_project_id) REFERENCES project (project_id) ON DELETE CASCADE,
  75. type_id integer NOT NULL,
  76. FOREIGN KEY (type_id) REFERENCES cvterm (cvterm_id) ON DELETE RESTRICT,
  77. CONSTRAINT project_relationship_c1 UNIQUE (subject_project_id, object_project_id, type_id)
  78. );
  79. COMMENT ON TABLE project_relationship IS 'A project can be composed of several smaller scale projects';
  80. COMMENT ON COLUMN project_relationship.type_id IS 'The type of relationship being stated, such as "is part of".';
  81. create table project_pub (
  82. project_pub_id serial not null,
  83. primary key (project_pub_id),
  84. project_id int not null,
  85. foreign key (project_id) references project (project_id) on delete cascade INITIALLY DEFERRED,
  86. pub_id int not null,
  87. foreign key (pub_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED,
  88. constraint project_pub_c1 unique (project_id,pub_id)
  89. );
  90. create index project_pub_idx1 on project_pub (project_id);
  91. create index project_pub_idx2 on project_pub (pub_id);
  92. COMMENT ON TABLE project_pub IS 'Linking project(s) to publication(s)';
  93. create table project_contact (
  94. project_contact_id serial not null,
  95. primary key (project_contact_id),
  96. project_id int not null,
  97. foreign key (project_id) references project (project_id) on delete cascade INITIALLY DEFERRED,
  98. contact_id int not null,
  99. foreign key (contact_id) references contact (contact_id) on delete cascade INITIALLY DEFERRED,
  100. constraint project_contact_c1 unique (project_id,contact_id)
  101. );
  102. create index project_contact_idx1 on project_contact (project_id);
  103. create index project_contact_idx2 on project_contact (contact_id);
  104. COMMENT ON TABLE project_contact IS 'Linking project(s) to contact(s)';
  105. ALTER TABLE stock alter organism_id drop not null;
  106. COMMENT ON COLUMN stock.organism_id IS 'The organism_id is the organism to which the stock belongs. This column is mandatory.';
  107. CREATE TABLE stock_relationship_cvterm (
  108. stock_relationship_cvterm_id SERIAL NOT NULL,
  109. PRIMARY KEY (stock_relationship_cvterm_id),
  110. stock_relationship_id integer NOT NULL,
  111. FOREIGN KEY (stock_relationship_id) references stock_relationship (stock_relationship_id) ON DELETE CASCADE INITIALLY DEFERRED,
  112. cvterm_id integer NOT NULL,
  113. FOREIGN KEY (cvterm_id) REFERENCES cvterm (cvterm_id) ON DELETE RESTRICT,
  114. pub_id integer,
  115. FOREIGN KEY (pub_id) REFERENCES pub (pub_id) ON DELETE RESTRICT
  116. );
  117. COMMENT ON TABLE stock_relationship_cvterm is 'For germplasm maintenance and pedigree data, stock_relationship. type_id will record cvterms such as "is a female parent of", "a parent for mutation", "is a group_id of", "is a source_id of", etc The cvterms for higher categories such as "generative", "derivative" or "maintenance" can be stored in table stock_relationship_cvterm';
  118. alter table stock_cvterm add column is_not boolean not null default false;
  119. alter table stock_cvterm add column rank integer not null default 0;
  120. alter table stock_cvterm drop constraint stock_cvterm_c1;
  121. alter table stock_cvterm add constraint stock_cvterm_c1 unique (stock_id,cvterm_id,pub_id,rank)
  122. ;
  123. create table stock_cvtermprop (
  124. stock_cvtermprop_id serial not null,
  125. primary key (stock_cvtermprop_id),
  126. stock_cvterm_id int not null,
  127. foreign key (stock_cvterm_id) references stock_cvterm (stock_cvterm_id) on delete cascade,
  128. type_id int not null,
  129. foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
  130. value text null,
  131. rank int not null default 0,
  132. constraint stock_cvtermprop_c1 unique (stock_cvterm_id,type_id,rank)
  133. );
  134. create index stock_cvtermprop_idx1 on stock_cvtermprop (stock_cvterm_id);
  135. create index stock_cvtermprop_idx2 on stock_cvtermprop (type_id);
  136. COMMENT ON TABLE stock_cvtermprop IS 'Extensible properties for
  137. stock to cvterm associations. Examples: GO evidence codes;
  138. qualifiers; metadata such as the date on which the entry was curated
  139. and the source of the association. See the stockprop table for
  140. meanings of type_id, value and rank.';
  141. COMMENT ON COLUMN stock_cvtermprop.type_id IS 'The name of the
  142. property/slot is a cvterm. The meaning of the property is defined in
  143. that cvterm. cvterms may come from the OBO evidence code cv.';
  144. COMMENT ON COLUMN stock_cvtermprop.value IS 'The value of the
  145. property, represented as text. Numeric values are converted to their
  146. text representation. This is less efficient than using native database
  147. types, but is easier to query.';
  148. COMMENT ON COLUMN stock_cvtermprop.rank IS 'Property-Value
  149. ordering. Any stock_cvterm can have multiple values for any particular
  150. property type - these are ordered in a list using rank, counting from
  151. zero. For properties that are single-valued rather than multi-valued,
  152. the default 0 value should be used.';
  153. create table stock_dbxrefprop (
  154. stock_dbxrefprop_id serial not null,
  155. primary key (stock_dbxrefprop_id),
  156. stock_dbxref_id int not null,
  157. foreign key (stock_dbxref_id) references stock_dbxref (stock_dbxref_id) on delete cascade INITIALLY DEFERRED,
  158. type_id int not null,
  159. foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
  160. value text null,
  161. rank int not null default 0,
  162. constraint stock_dbxrefprop_c1 unique (stock_dbxref_id,type_id,rank)
  163. );
  164. create index stock_dbxrefprop_idx1 on stock_dbxrefprop (stock_dbxref_id);
  165. create index stock_dbxrefprop_idx2 on stock_dbxrefprop (type_id);
  166. COMMENT ON TABLE stock_dbxrefprop IS 'A stock_dbxref can have any number of
  167. slot-value property tags attached to it. This is useful for storing properties related to dbxref annotations of stocks, such as evidence codes, and references, and metadata, such as create/modify dates. This is an alternative to
  168. hardcoding a list of columns in the relational schema, and is
  169. completely extensible. There is a unique constraint, stock_dbxrefprop_c1, for
  170. the combination of stock_dbxref_id, rank, and type_id. Multivalued property-value pairs must be differentiated by rank.';
  171. -- VIEW gffatts: a view to get feature attributes in a format that
  172. -- will make it easy to convert them to GFF attributes
  173. CREATE OR REPLACE VIEW gffatts (
  174. feature_id,
  175. type,
  176. attribute
  177. ) AS
  178. SELECT feature_id, 'Ontology_term' AS type, s.name AS attribute
  179. FROM cvterm s, feature_cvterm fs
  180. WHERE fs.cvterm_id = s.cvterm_id
  181. UNION ALL
  182. SELECT feature_id, 'Dbxref' AS type, d.name || ':' || s.accession AS attribute
  183. FROM dbxref s, feature_dbxref fs, db d
  184. WHERE fs.dbxref_id = s.dbxref_id and s.db_id = d.db_id
  185. UNION ALL
  186. SELECT feature_id, 'Alias' AS type, s.name AS attribute
  187. FROM synonym s, feature_synonym fs
  188. WHERE fs.synonym_id = s.synonym_id
  189. UNION ALL
  190. SELECT fp.feature_id,cv.name,fp.value
  191. FROM featureprop fp, cvterm cv
  192. WHERE fp.type_id = cv.cvterm_id
  193. UNION ALL
  194. SELECT feature_id, 'pub' AS type, s.series_name || ':' || s.title AS attribute
  195. FROM pub s, feature_pub fs
  196. WHERE fs.pub_id = s.pub_id;
  197. CREATE OR REPLACE VIEW gff3atts (
  198. feature_id,
  199. type,
  200. attribute
  201. ) AS
  202. SELECT feature_id,
  203. 'Ontology_term' AS type,
  204. CASE WHEN db.name like '%Gene Ontology%' THEN 'GO:'|| dbx.accession
  205. WHEN db.name like 'Sequence Ontology%' THEN 'SO:'|| dbx.accession
  206. ELSE CAST(db.name||':'|| dbx.accession AS varchar)
  207. END
  208. FROM cvterm s, dbxref dbx, feature_cvterm fs, db
  209. WHERE fs.cvterm_id = s.cvterm_id and s.dbxref_id=dbx.dbxref_id and
  210. db.db_id = dbx.db_id
  211. UNION ALL
  212. SELECT feature_id, 'Dbxref' AS type, d.name || ':' || s.accession AS
  213. attribute
  214. FROM dbxref s, feature_dbxref fs, db d
  215. WHERE fs.dbxref_id = s.dbxref_id and s.db_id = d.db_id and
  216. d.name != 'GFF_source'
  217. UNION ALL
  218. SELECT f.feature_id, 'Alias' AS type, s.name AS attribute
  219. FROM synonym s, feature_synonym fs, feature f
  220. WHERE fs.synonym_id = s.synonym_id and f.feature_id = fs.feature_id and
  221. f.name != s.name and f.uniquename != s.name
  222. UNION ALL
  223. SELECT fp.feature_id,cv.name,fp.value
  224. FROM featureprop fp, cvterm cv
  225. WHERE fp.type_id = cv.cvterm_id
  226. UNION ALL
  227. SELECT feature_id, 'pub' AS type, s.series_name || ':' || s.title AS
  228. attribute
  229. FROM pub s, feature_pub fs
  230. WHERE fs.pub_id = s.pub_id
  231. UNION ALL
  232. SELECT fr.subject_id as feature_id, 'Parent' as type, parent.uniquename
  233. as attribute
  234. FROM feature_relationship fr, feature parent
  235. WHERE fr.object_id=parent.feature_id AND fr.type_id = (SELECT cvterm_id
  236. FROM cvterm WHERE name='part_of' and cv_id in (select cv_id
  237. FROM cv WHERE name='relationship'))
  238. UNION ALL
  239. SELECT fr.subject_id as feature_id, 'Derives_from' as type,
  240. parent.uniquename as attribute
  241. FROM feature_relationship fr, feature parent
  242. WHERE fr.object_id=parent.feature_id AND fr.type_id = (SELECT cvterm_id
  243. FROM cvterm WHERE name='derives_from' and cv_id in (select cv_id
  244. FROM cv WHERE name='relationship'))
  245. UNION ALL
  246. SELECT fl.feature_id, 'Target' as type, target.name || ' ' || fl.fmin+1
  247. || ' ' || fl.fmax || ' ' || fl.strand as attribute
  248. FROM featureloc fl, feature target
  249. WHERE fl.srcfeature_id=target.feature_id
  250. AND fl.rank != 0
  251. UNION ALL
  252. SELECT feature_id, 'ID' as type, uniquename as attribute
  253. FROM feature
  254. WHERE type_id NOT IN (SELECT cvterm_id FROM cvterm WHERE name='CDS')
  255. UNION ALL
  256. SELECT feature_id, 'chado_feature_id' as type, CAST(feature_id AS
  257. varchar) as attribute
  258. FROM feature
  259. UNION ALL
  260. SELECT feature_id, 'Name' as type, name as attribute
  261. FROM feature;
  262. -- =================================================================
  263. -- Dependencies:
  264. --
  265. -- :import feature from sequence
  266. -- :import cvterm from cv
  267. -- :import pub from pub
  268. -- :import phenotype from phenotype
  269. -- :import organism from organism
  270. -- :import genotype from genetic
  271. -- :import contact from contact
  272. -- :import project from project
  273. -- :import stock from stock
  274. -- :import synonym
  275. -- =================================================================
  276. -- this probably needs some work, depending on how cross-database we
  277. -- want to be. In Postgres, at least, there are much better ways to
  278. -- represent geo information.
  279. CREATE TABLE nd_geolocation (
  280. nd_geolocation_id serial PRIMARY KEY NOT NULL,
  281. description character varying(255),
  282. latitude real,
  283. longitude real,
  284. geodetic_datum character varying(32),
  285. altitude real
  286. );
  287. COMMENT ON TABLE nd_geolocation IS 'The geo-referencable location of the stock. NOTE: This entity is subject to change as a more general and possibly more OpenGIS-compliant geolocation module may be introduced into Chado.';
  288. COMMENT ON COLUMN nd_geolocation.description IS 'A textual representation of the location, if this is the original georeference. Optional if the original georeference is available in lat/long coordinates.';
  289. COMMENT ON COLUMN nd_geolocation.latitude IS 'The decimal latitude coordinate of the georeference, using positive and negative sign to indicate N and S, respectively.';
  290. COMMENT ON COLUMN nd_geolocation.longitude IS 'The decimal longitude coordinate of the georeference, using positive and negative sign to indicate E and W, respectively.';
  291. COMMENT ON COLUMN nd_geolocation.geodetic_datum IS 'The geodetic system on which the geo-reference coordinates are based. For geo-references measured between 1984 and 2010, this will typically be WGS84.';
  292. COMMENT ON COLUMN nd_geolocation.altitude IS 'The altitude (elevation) of the location in meters. If the altitude is only known as a range, this is the average, and altitude_dev will hold half of the width of the range.';
  293. CREATE TABLE nd_experiment (
  294. nd_experiment_id serial PRIMARY KEY NOT NULL,
  295. nd_geolocation_id integer NOT NULL references nd_geolocation (nd_geolocation_id) on delete cascade INITIALLY DEFERRED,
  296. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
  297. );
  298. --
  299. --used to be nd_diversityexperiment_project
  300. --then was nd_assay_project
  301. CREATE TABLE nd_experiment_project (
  302. nd_experiment_project_id serial PRIMARY KEY NOT NULL,
  303. project_id integer not null references project (project_id) on delete cascade INITIALLY DEFERRED,
  304. nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED
  305. );
  306. CREATE TABLE nd_experimentprop (
  307. nd_experimentprop_id serial PRIMARY KEY NOT NULL,
  308. nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
  309. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED ,
  310. value text null,
  311. rank integer NOT NULL default 0,
  312. constraint nd_experimentprop_c1 unique (nd_experiment_id,type_id,rank)
  313. );
  314. CREATE TABLE nd_experiment_pub (
  315. nd_experiment_pub_id serial PRIMARY KEY not null,
  316. nd_experiment_id int not null,
  317. foreign key (nd_experiment_id) references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
  318. pub_id int not null,
  319. foreign key (pub_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED,
  320. constraint nd_experiment_pub_c1 unique (nd_experiment_id,pub_id)
  321. );
  322. create index nd_experiment_pub_idx1 on nd_experiment_pub (nd_experiment_id);
  323. create index nd_experiment_pub_idx2 on nd_experiment_pub (pub_id);
  324. COMMENT ON TABLE nd_experiment_pub IS 'Linking nd_experiment(s) to publication(s)';
  325. CREATE TABLE nd_geolocationprop (
  326. nd_geolocationprop_id serial PRIMARY KEY NOT NULL,
  327. nd_geolocation_id integer NOT NULL references nd_geolocation (nd_geolocation_id) on delete cascade INITIALLY DEFERRED,
  328. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
  329. value text null,
  330. rank integer NOT NULL DEFAULT 0,
  331. constraint nd_geolocationprop_c1 unique (nd_geolocation_id,type_id,rank)
  332. );
  333. COMMENT ON TABLE nd_geolocationprop IS 'Property/value associations for geolocations. This table can store the properties such as location and environment';
  334. COMMENT ON COLUMN nd_geolocationprop.type_id IS 'The name of the property as a reference to a controlled vocabulary term.';
  335. COMMENT ON COLUMN nd_geolocationprop.value IS 'The value of the property.';
  336. COMMENT ON COLUMN nd_geolocationprop.rank IS 'The rank of the property value, if the property has an array of values.';
  337. CREATE TABLE nd_protocol (
  338. nd_protocol_id serial PRIMARY KEY NOT NULL,
  339. name character varying(255) NOT NULL unique,
  340. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
  341. );
  342. COMMENT ON TABLE nd_protocol IS 'A protocol can be anything that is done as part of the experiment.';
  343. COMMENT ON COLUMN nd_protocol.name IS 'The protocol name.';
  344. CREATE TABLE nd_reagent (
  345. nd_reagent_id serial PRIMARY KEY NOT NULL,
  346. name character varying(80) NOT NULL,
  347. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
  348. feature_id integer
  349. );
  350. COMMENT ON TABLE nd_reagent IS 'A reagent such as a primer, an enzyme, an adapter oligo, a linker oligo. Reagents are used in genotyping experiments, or in any other kind of experiment.';
  351. COMMENT ON COLUMN nd_reagent.name IS 'The name of the reagent. The name should be unique for a given type.';
  352. COMMENT ON COLUMN nd_reagent.type_id IS 'The type of the reagent, for example linker oligomer, or forward primer.';
  353. COMMENT ON COLUMN nd_reagent.feature_id IS 'If the reagent is a primer, the feature that it corresponds to. More generally, the corresponding feature for any reagent that has a sequence that maps to another sequence.';
  354. CREATE TABLE nd_protocol_reagent (
  355. nd_protocol_reagent_id serial PRIMARY KEY NOT NULL,
  356. nd_protocol_id integer NOT NULL references nd_protocol (nd_protocol_id) on delete cascade INITIALLY DEFERRED,
  357. reagent_id integer NOT NULL references nd_reagent (nd_reagent_id) on delete cascade INITIALLY DEFERRED,
  358. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
  359. );
  360. CREATE TABLE nd_protocolprop (
  361. nd_protocolprop_id serial PRIMARY KEY NOT NULL,
  362. nd_protocol_id integer NOT NULL references nd_protocol (nd_protocol_id) on delete cascade INITIALLY DEFERRED,
  363. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
  364. value text null,
  365. rank integer DEFAULT 0 NOT NULL,
  366. constraint nd_protocolprop_c1 unique (nd_protocol_id,type_id,rank)
  367. );
  368. COMMENT ON TABLE nd_protocolprop IS 'Property/value associations for protocol.';
  369. COMMENT ON COLUMN nd_protocolprop.nd_protocol_id IS 'The protocol to which the property applies.';
  370. COMMENT ON COLUMN nd_protocolprop.type_id IS 'The name of the property as a reference to a controlled vocabulary term.';
  371. COMMENT ON COLUMN nd_protocolprop.value IS 'The value of the property.';
  372. COMMENT ON COLUMN nd_protocolprop.rank IS 'The rank of the property value, if the property has an array of values.';
  373. CREATE TABLE nd_experiment_stock (
  374. nd_experiment_stock_id serial PRIMARY KEY NOT NULL,
  375. nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
  376. stock_id integer NOT NULL references stock (stock_id) on delete cascade INITIALLY DEFERRED,
  377. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
  378. );
  379. COMMENT ON TABLE nd_experiment_stock IS 'Part of a stock or a clone of a stock that is used in an experiment';
  380. COMMENT ON COLUMN nd_experiment_stock.stock_id IS 'stock used in the extraction or the corresponding stock for the clone';
  381. CREATE TABLE nd_experiment_protocol (
  382. nd_experiment_protocol_id serial PRIMARY KEY NOT NULL,
  383. nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
  384. nd_protocol_id integer NOT NULL references nd_protocol (nd_protocol_id) on delete cascade INITIALLY DEFERRED
  385. );
  386. COMMENT ON TABLE nd_experiment_protocol IS 'Linking table: experiments to the protocols they involve.';
  387. CREATE TABLE nd_experiment_phenotype (
  388. nd_experiment_phenotype_id serial PRIMARY KEY NOT NULL,
  389. nd_experiment_id integer NOT NULL REFERENCES nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
  390. phenotype_id integer NOT NULL references phenotype (phenotype_id) on delete cascade INITIALLY DEFERRED,
  391. constraint nd_experiment_phenotype_c1 unique (nd_experiment_id,phenotype_id)
  392. );
  393. COMMENT ON TABLE nd_experiment_phenotype IS 'Linking table: experiments to the phenotypes they produce. There is a one-to-one relationship between an experiment and a phenotype since each phenotype record should point to one experiment. Add a new experiment_id for each phenotype record.';
  394. CREATE TABLE nd_experiment_genotype (
  395. nd_experiment_genotype_id serial PRIMARY KEY NOT NULL,
  396. nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
  397. genotype_id integer NOT NULL references genotype (genotype_id) on delete cascade INITIALLY DEFERRED ,
  398. constraint nd_experiment_genotype_c1 unique (nd_experiment_id,genotype_id)
  399. );
  400. COMMENT ON TABLE nd_experiment_genotype IS 'Linking table: experiments to the genotypes they produce. There is a one-to-one relationship between an experiment and a genotype since each genotype record should point to one experiment. Add a new experiment_id for each genotype record.';
  401. CREATE TABLE nd_reagent_relationship (
  402. nd_reagent_relationship_id serial PRIMARY KEY NOT NULL,
  403. subject_reagent_id integer NOT NULL references nd_reagent (nd_reagent_id) on delete cascade INITIALLY DEFERRED,
  404. object_reagent_id integer NOT NULL references nd_reagent (nd_reagent_id) on delete cascade INITIALLY DEFERRED,
  405. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
  406. );
  407. COMMENT ON TABLE nd_reagent_relationship IS 'Relationships between reagents. Some reagents form a group. i.e., they are used all together or not at all. Examples are adapter/linker/enzyme experiment reagents.';
  408. COMMENT ON COLUMN nd_reagent_relationship.subject_reagent_id IS 'The subject reagent in the relationship. In parent/child terminology, the subject is the child. For example, in "linkerA 3prime-overhang-linker enzymeA" linkerA is the subject, 3prime-overhand-linker is the type, and enzymeA is the object.';
  409. COMMENT ON COLUMN nd_reagent_relationship.object_reagent_id IS 'The object reagent in the relationship. In parent/child terminology, the object is the parent. For example, in "linkerA 3prime-overhang-linker enzymeA" linkerA is the subject, 3prime-overhand-linker is the type, and enzymeA is the object.';
  410. COMMENT ON COLUMN nd_reagent_relationship.type_id IS 'The type (or predicate) of the relationship. For example, in "linkerA 3prime-overhang-linker enzymeA" linkerA is the subject, 3prime-overhand-linker is the type, and enzymeA is the object.';
  411. CREATE TABLE nd_reagentprop (
  412. nd_reagentprop_id serial PRIMARY KEY NOT NULL,
  413. nd_reagent_id integer NOT NULL references nd_reagent (nd_reagent_id) on delete cascade INITIALLY DEFERRED,
  414. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
  415. value text null,
  416. rank integer DEFAULT 0 NOT NULL,
  417. constraint nd_reagentprop_c1 unique (nd_reagent_id,type_id,rank)
  418. );
  419. CREATE TABLE nd_experiment_stockprop (
  420. nd_experiment_stockprop_id serial PRIMARY KEY NOT NULL,
  421. nd_experiment_stock_id integer NOT NULL references nd_experiment_stock (nd_experiment_stock_id) on delete cascade INITIALLY DEFERRED,
  422. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
  423. value text null,
  424. rank integer DEFAULT 0 NOT NULL,
  425. constraint nd_experiment_stockprop_c1 unique (nd_experiment_stock_id,type_id,rank)
  426. );
  427. COMMENT ON TABLE nd_experiment_stockprop IS 'Property/value associations for experiment_stocks. This table can store the properties such as treatment';
  428. COMMENT ON COLUMN nd_experiment_stockprop.nd_experiment_stock_id IS 'The experiment_stock to which the property applies.';
  429. COMMENT ON COLUMN nd_experiment_stockprop.type_id IS 'The name of the property as a reference to a controlled vocabulary term.';
  430. COMMENT ON COLUMN nd_experiment_stockprop.value IS 'The value of the property.';
  431. COMMENT ON COLUMN nd_experiment_stockprop.rank IS 'The rank of the property value, if the property has an array of values.';
  432. CREATE TABLE nd_experiment_stock_dbxref (
  433. nd_experiment_stock_dbxref_id serial PRIMARY KEY NOT NULL,
  434. nd_experiment_stock_id integer NOT NULL references nd_experiment_stock (nd_experiment_stock_id) on delete cascade INITIALLY DEFERRED,
  435. dbxref_id integer NOT NULL references dbxref (dbxref_id) on delete cascade INITIALLY DEFERRED
  436. );
  437. COMMENT ON TABLE nd_experiment_stock_dbxref IS 'Cross-reference experiment_stock to accessions, images, etc';
  438. CREATE TABLE nd_experiment_dbxref (
  439. nd_experiment_dbxref_id serial PRIMARY KEY NOT NULL,
  440. nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
  441. dbxref_id integer NOT NULL references dbxref (dbxref_id) on delete cascade INITIALLY DEFERRED
  442. );
  443. COMMENT ON TABLE nd_experiment_dbxref IS 'Cross-reference experiment to accessions, images, etc';
  444. CREATE TABLE nd_experiment_contact (
  445. nd_experiment_contact_id serial PRIMARY KEY NOT NULL,
  446. nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
  447. contact_id integer NOT NULL references contact (contact_id) on delete cascade INITIALLY DEFERRED
  448. );