Skip to content

Commit 4332597

Browse files
committed
DBSchema changes and initial layour of the patch
1 parent 6fcd021 commit 4332597

File tree

3 files changed

+634
-600
lines changed

3 files changed

+634
-600
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- May 6, 2015
2+
-- We attach the prep template directly to the study. The raw data is no longer
3+
-- attached to the study directly, the prep template point to them. This will
4+
-- make the RawData to be effectively just a container for the raw files,
5+
-- which is how it was acting previously.
6+
7+
CREATE TABLE qiita.study_prep_template (
8+
study_id bigint NOT NULL,
9+
prep_template_id bigint NOT NULL,
10+
CONSTRAINT idx_study_raw_data PRIMARY KEY ( study_id, prep_template_id )
11+
) ;
12+
13+
CREATE INDEX idx_study_prep_template_0 ON qiita.study_prep_template ( study_id ) ;
14+
15+
CREATE INDEX idx_study_prep_template_1 ON qiita.study_prep_template ( prep_template_id ) ;
16+
17+
COMMENT ON TABLE qiita.study_prep_template IS 'links study to its prep templates';
18+
19+
ALTER TABLE qiita.study_prep_template ADD CONSTRAINT fk_study_prep_template_study FOREIGN KEY ( study_id ) REFERENCES qiita.study( study_id ) ;
20+
21+
ALTER TABLE qiita.study_prep_template ADD CONSTRAINT fk_study_prep_template_pt FOREIGN KEY ( prep_template_id ) REFERENCES qiita.prep_template( prep_template_id ) ;
22+
23+
-- Connect the existing prep templates in the system with their studies
24+
WITH pt_st AS (SELECT prep_template_id, study_id
25+
FROM qiita.prep_template
26+
JOIN qiita.study_raw_data USING (raw_data_id))
27+
28+
29+
DROP TABLE qiita.study_raw_data;
30+

qiita_db/support_files/qiita-db.dbs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -747,9 +747,6 @@
747747
<index name="idx_common_prep_info_1" unique="NORMAL" >
748748
<column name="prep_template_id" />
749749
</index>
750-
<fk name="fk_common_prep_info" to_schema="qiita" to_table="study_sample" >
751-
<fk_column name="sample_id" pk="sample_id" />
752-
</fk>
753750
<fk name="fk_prep_template" to_schema="qiita" to_table="prep_template" >
754751
<fk_column name="prep_template_id" pk="prep_template_id" />
755752
</fk>
@@ -1340,6 +1337,27 @@ Controlled Vocabulary]]></comment>
13401337
<fk_column name="study_id" pk="study_id" />
13411338
</fk>
13421339
</table>
1340+
<table name="study_prep_template" >
1341+
<comment>links study to its prep templates</comment>
1342+
<column name="study_id" type="bigint" jt="-5" mandatory="y" />
1343+
<column name="prep_template_id" type="bigint" jt="-5" mandatory="y" />
1344+
<index name="idx_study_raw_data" unique="PRIMARY_KEY" >
1345+
<column name="study_id" />
1346+
<column name="prep_template_id" />
1347+
</index>
1348+
<index name="idx_study_raw_data_0" unique="NORMAL" >
1349+
<column name="study_id" />
1350+
</index>
1351+
<index name="idx_study_raw_data_1" unique="NORMAL" >
1352+
<column name="prep_template_id" />
1353+
</index>
1354+
<fk name="fk_study_prep_template_study" to_schema="qiita" to_table="study" >
1355+
<fk_column name="study_id" pk="study_id" />
1356+
</fk>
1357+
<fk name="fk_study_prep_template_pt" to_schema="qiita" to_table="prep_template" >
1358+
<fk_column name="prep_template_id" pk="prep_template_id" />
1359+
</fk>
1360+
</table>
13431361
<table name="study_preprocessed_data" >
13441362
<column name="study_id" type="bigint" jt="-5" mandatory="y" />
13451363
<column name="preprocessed_data_id" type="bigint" jt="-5" mandatory="y" />
@@ -1380,24 +1398,6 @@ Controlled Vocabulary]]></comment>
13801398
<fk_column name="processed_data_id" pk="processed_data_id" />
13811399
</fk>
13821400
</table>
1383-
<table name="study_raw_data" >
1384-
<comment>links study to its raw data</comment>
1385-
<column name="study_id" type="bigint" jt="-5" mandatory="y" />
1386-
<column name="raw_data_id" type="bigint" jt="-5" mandatory="y" />
1387-
<index name="idx_study_raw_data" unique="NORMAL" >
1388-
<column name="study_id" />
1389-
</index>
1390-
<index name="idx_study_raw_data_0" unique="PRIMARY_KEY" >
1391-
<column name="study_id" />
1392-
<column name="raw_data_id" />
1393-
</index>
1394-
<fk name="fk_study_raw_data_study" to_schema="qiita" to_table="study" >
1395-
<fk_column name="study_id" pk="study_id" />
1396-
</fk>
1397-
<fk name="fk_study_raw_data_raw_data" to_schema="qiita" to_table="raw_data" >
1398-
<fk_column name="raw_data_id" pk="raw_data_id" />
1399-
</fk>
1400-
</table>
14011401
<table name="study_sample" >
14021402
<comment>Required info for each sample. One row is one sample.</comment>
14031403
<column name="sample_id" type="varchar" jt="12" mandatory="y" />
@@ -1522,7 +1522,6 @@ Controlled Vocabulary]]></comment>
15221522
<entity schema="qiita" name="study_preprocessed_data" color="c0d4f3" x="1545" y="720" />
15231523
<entity schema="qiita" name="study_users" color="d0def5" x="1065" y="60" />
15241524
<entity schema="qiita" name="sample_x" color="d0def5" x="1635" y="165" />
1525-
<entity schema="qiita" name="study_raw_data" color="d0def5" x="1575" y="510" />
15261525
<entity schema="qiita" name="processed_filepath" color="c0d4f3" x="1065" y="945" />
15271526
<entity schema="qiita" name="command" color="d0def5" x="210" y="1110" />
15281527
<entity schema="qiita" name="logging" color="c0d4f3" x="1335" y="1290" />
@@ -1540,27 +1539,20 @@ Controlled Vocabulary]]></comment>
15401539
<entity schema="qiita" name="preprocessed_processed_data" color="b2cdf7" x="1275" y="870" />
15411540
<entity schema="qiita" name="qiita_user" color="d0def5" x="330" y="90" />
15421541
<entity schema="qiita" name="prep_y" color="d0def5" x="1230" y="195" />
1543-
<entity schema="qiita" name="prep_columns" color="b2cdf7" x="1275" y="345" />
1544-
<entity schema="qiita" name="raw_filepath" color="c0d4f3" x="1080" y="510" />
1545-
<entity schema="qiita" name="filetype" color="d0def5" x="1560" y="600" />
15461542
<entity schema="qiita" name="filepath_type" color="c0d4f3" x="585" y="885" />
15471543
<entity schema="qiita" name="checksum_algorithm" color="b2cdf7" x="735" y="885" />
15481544
<entity schema="qiita" name="data_type" color="d0def5" x="690" y="1020" />
15491545
<entity schema="qiita" name="user_level" color="d0def5" x="165" y="75" />
15501546
<entity schema="qiita" name="job_status" color="d0def5" x="210" y="1020" />
15511547
<entity schema="qiita" name="severity" color="c0d4f3" x="1470" y="1290" />
1552-
<entity schema="qiita" name="prep_template" color="b2cdf7" x="1065" y="360" />
1553-
<entity schema="qiita" name="raw_data" color="d0def5" x="1275" y="495" />
15541548
<entity schema="qiita" name="job" color="d0def5" x="405" y="1005" />
15551549
<entity schema="qiita" name="filepath" color="c0d4f3" x="645" y="675" />
15561550
<entity schema="qiita" name="data_directory" color="b2cdf7" x="840" y="585" />
15571551
<entity schema="qiita" name="term" color="d0def5" x="810" y="1650" />
15581552
<entity schema="qiita" name="environmental_package" color="b2cdf7" x="2250" y="150" />
15591553
<entity schema="qiita" name="study_environmental_package" color="b2cdf7" x="2250" y="45" />
15601554
<entity schema="qiita" name="timeseries_type" color="c0d4f3" x="1680" y="615" />
1561-
<entity schema="qiita" name="prep_template_filepath" color="b2cdf7" x="1035" y="600" />
15621555
<entity schema="qiita" name="sample_template_filepath" color="b2cdf7" x="1050" y="795" />
1563-
<entity schema="qiita" name="prep_template_preprocessed_data" color="b2cdf7" x="750" y="450" />
15641556
<entity schema="qiita" name="preprocessed_data" color="c0d4f3" x="1260" y="675" />
15651557
<entity schema="qiita" name="reference" color="c0d4f3" x="2280" y="960" />
15661558
<entity schema="qiita" name="preprocessed_sequence_454_params" color="c0d4f3" x="1740" y="960" />
@@ -1582,8 +1574,16 @@ Controlled Vocabulary]]></comment>
15821574
<entity schema="qiita" name="processed_data_status" color="c0d4f3" x="1500" y="1050" />
15831575
<entity schema="qiita" name="portal_type" color="c0d4f3" x="1995" y="660" />
15841576
<entity schema="qiita" name="analysis_sample" color="d0def5" x="45" y="1170" />
1585-
<entity schema="qiita" name="study_sample" color="d0def5" x="1410" y="120" />
1586-
<entity schema="qiita" name="prep_template_sample" color="d0def5" x="1050" y="165" />
1577+
<entity schema="qiita" name="study_sample" color="d0def5" x="1515" y="105" />
1578+
<entity schema="qiita" name="raw_data" color="d0def5" x="1020" y="300" />
1579+
<entity schema="qiita" name="filetype" color="d0def5" x="1035" y="180" />
1580+
<entity schema="qiita" name="prep_template_preprocessed_data" color="b2cdf7" x="1275" y="555" />
1581+
<entity schema="qiita" name="prep_template" color="b2cdf7" x="1305" y="375" />
1582+
<entity schema="qiita" name="raw_filepath" color="c0d4f3" x="1035" y="435" />
1583+
<entity schema="qiita" name="prep_template_filepath" color="b2cdf7" x="1035" y="525" />
1584+
<entity schema="qiita" name="study_prep_template" color="d0def5" x="1590" y="420" />
1585+
<entity schema="qiita" name="prep_columns" color="b2cdf7" x="1470" y="285" />
1586+
<entity schema="qiita" name="prep_template_sample" color="d0def5" x="1335" y="195" />
15871587
<group name="Group_analyses" color="c4e0f9" >
15881588
<comment>analysis tables</comment>
15891589
<entity schema="qiita" name="analysis" />
@@ -1610,7 +1610,7 @@ Controlled Vocabulary]]></comment>
16101610
<entity schema="qiita" name="study_sample_columns" />
16111611
<entity schema="qiita" name="raw_data" />
16121612
<entity schema="qiita" name="filetype" />
1613-
<entity schema="qiita" name="study_raw_data" />
1613+
<entity schema="qiita" name="study_prep_template" />
16141614
<entity schema="qiita" name="sample_x" />
16151615
<entity schema="qiita" name="preprocessed_spectra_params" />
16161616
<entity schema="qiita" name="preprocessed_sequence_illumina_params" />

0 commit comments

Comments
 (0)