Changes between Version 2 and Version 3 of DespoinaLog_molgenis35Tomolgenis14


Ignore:
Timestamp:
2013-02-22T11:24:06+01:00 (12 years ago)
Author:
antonak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DespoinaLog_molgenis35Tomolgenis14

    v2 v3  
    22
    33{{{
     4
     5=============================WITHOUT COMMENTS ===========================================
     6
    47CREATE TABLE `BiobankSubCategory` (
    5 `id` int(11) NOT NULL,
    6 
    7 PRIMARY KEY (`id`),
    8 
    9 CONSTRAINT `biobanksubcategory_ibfk_1` FOREIGN KEY (`id`) REFERENCES `OntologyTerm` (`id`) ON DELETE CASCADE
    10 
     8  `id` int(11) NOT NULL,
     9  PRIMARY KEY (`id`),
     10  CONSTRAINT `biobanksubcategory_ibfk_1` FOREIGN KEY (`id`) REFERENCES `OntologyTerm` (`id`) ON DELETE CASCADE
    1111) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
    1212
    1313
     14INSERT INTO BiobankSubCategory (id)
     15SELECT id
     16FROM BiobankCategory
     17WHERE id  NOT IN ("281", "284", "285") ;
     18
     19CREATE TABLE BiobankPersonRole (
     20        id INTEGER NOT NULL
     21        , PRIMARY KEY(id)
     22);
     23
     24alter table OntologyTerm modify   column __Type enum('OntologyTerm','PersonRole','Species','AlternateId','BiobankCategory','BiobankTopic','BiobankDataType', 'BiobankSubCategory','BiobankPersonRole');
     25
     26
     27ALTER TABLE Biobank DROP FOREIGN KEY biobank_ibfk_5;
     28
     29ALTER TABLE BiobankSubCategory ADD FOREIGN KEY (id) REFERENCES OntologyTerm (id) ON DELETE CASCADE;
     30
     31ALTER TABLE `BiobankSubCategory` 
     32ADD CONSTRAINT `biobank_ibfk_5`
     33    FOREIGN KEY (`id`) REFERENCES OntologyTerm (id) ON DELETE CASCADE; AUTO UPARXEI HDH APO THN DHMIOURGIA TOU)
     34
     35ALTER TABLE Biobank ADD FOREIGN KEY (SubCategory) REFERENCES BiobankSubCategory (id) ON DELETE RESTRICT;
     36
     37ALTER TABLE `Biobank` 
     38ADD CONSTRAINT `biobank_ibfk_885`
     39    FOREIGN KEY (`SubCategory`) REFERENCES BiobankSubCategory (id)  ON DELETE CASCADE;
     40
     41
     42
     43DELETE FROM BiobankCategory
     44WHERE id  NOT IN ("281", "284", "285") ;   
     45
     46
     47
     48ALTER TABLE BiobankPersonRole ADD FOREIGN KEY (id) REFERENCES PersonRole (id) ON DELETE CASCADE;
     49
     50
     51ALTER TABLE `BiobankPersonRole` 
     52ADD CONSTRAINT `BiobankPersonRole_ibfk_33`
     53    FOREIGN KEY (`id`) REFERENCES PersonRole (id)  ON DELETE CASCADE;
     54
     55UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='282';
     56UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='283';
     57UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='286';
     58UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='287';
     59UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='288';
     60UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='289';
     61UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='290';
     62UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='291';
     63UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='292';
     64UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='293';
     65UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='295';
     66UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='296';
     67UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='297';
     68UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='298';
     69UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='564';
     70UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='299';
     71UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='294';
     72
     73
     74
     75select * from OntologyTerm where name="Software Engineer";
     76delete from OntologyTerm where id=561;
     77select * from BiobankPersonRole;
     78insert into BiobankPersonRole values(561);
     79
     80select * from OntologyTerm where name="coordinator";
     81delete from OntologyTerm where id=593;
     82select * from BiobankPersonRole;
     83insert into BiobankPersonRole values(277);
     84
     85select * from OntologyTerm where name="postdoc";
     86delete from OntologyTerm where id=594;
     87 select * from BiobankPersonRole;
     88insert into BiobankPersonRole values(278);
     89
     90select * from OntologyTerm where name="administrator";
     91delete from OntologyTerm where id=595;
     92select * from BiobankPersonRole;
     93insert into BiobankPersonRole values(279);
     94
     95
     96select * from OntologyTerm where name="IT responsible";
     97delete from OntologyTerm where id=596;
     98select * from BiobankPersonRole;
     99insert into BiobankPersonRole values(280);
     100
     101 
     102COMMIT;
     103
     104======================================================================================
     105SubCategory
     106biobank_ibfk_1
     107  CONSTRAINT `biobank_ibfk_5` FOREIGN KEY (`SubCategory`) REFERENCES `BiobankSubCategory` (`id`)
     108  CONSTRAINT `biobank_ibfk_5` FOREIGN KEY (`SubCategory`) REFERENCES `BiobankSubCategory` (`id`),
     109
     110
     111=============================WITH COMMENTS ===========================================
     112
     113CREATE TABLE `BiobankSubCategory` (
     114  `id` int(11) NOT NULL,
     115  PRIMARY KEY (`id`),
     116  CONSTRAINT `biobanksubcategory_ibfk_1` FOREIGN KEY (`id`) REFERENCES `OntologyTerm` (`id`) ON DELETE CASCADE
     117) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
     118
     119/* move data from BiobankCategory to BiobankSubCategory table */
     120INSERT INTO BiobankSubCategory (id)
     121SELECT id
     122FROM BiobankCategory
     123WHERE id  NOT IN ("281", "284", "285") ;
     124/*WHERE name NOT IN ("A. Core Biobanks, DNA available", "B: Supporting biobanks, DNA not yet available" ,"C: Biobanken in opbouw") ;* - IF NEEDED CORRECT THE IDs/
     125
     126/* alter constraints */
     127ALTER TABLE Biobank DROP FOREIGN KEY biobank_ibfk_5;
     128
     129
     130ALTER TABLE BiobankSubCategory ADD FOREIGN KEY (id) REFERENCES OntologyTerm (id) ON DELETE CASCADE;
     131NOT OK : ERROR 1050 (42S01): Table './bbmri/BiobankSubCategory' already exists
     132THEN USE : 
     133ALTER TABLE `BiobankSubCategory` 
     134ADD CONSTRAINT `id`
     135    FOREIGN KEY (`id`) REFERENCES OntologyTerm (id) ON DELETE CASCADE;
     136
     137ALTER TABLE Biobank ADD FOREIGN KEY (SubCategory) REFERENCES BiobankSubCategory (id) ON DELETE RESTRICT;
     138NOT OK : ERROR 1050 (42S01): Table './bbmri/Biobank' already exists
     139THEN USE :
     140ALTER TABLE `Biobank` 
     141ADD CONSTRAINT `SubCategory`
     142    FOREIGN KEY (`SubCategory`) REFERENCES BiobankSubCategory (id)  ON DELETE CASCADE;
     143
     144
     145
     146/* delete moved data from BiobankCategory */
     147DELETE FROM BiobankCategory
     148WHERE id  NOT IN ("281", "284", "285") ;   
     149/*IF NEEDED CORRECT THE IDs
     150WHERE name IN ("A. Core Biobanks, DNA available", "B: Supporting biobanks, DNA not yet available" ,"C: Biobanken in opbouw") ;
     151*/
     152
     153CREATE TABLE BiobankPersonRole (
     154        id INTEGER NOT NULL
     155        , PRIMARY KEY(id)
     156);
     157
     158ALTER TABLE BiobankPersonRole ADD FOREIGN KEY (id) REFERENCES PersonRole (id) ON DELETE CASCADE;
     159
     160alter table OntologyTerm modify   column __Type enum('OntologyTerm','PersonRole','Species','AlternateId','BiobankCategory','BiobankTopic','BiobankDataType', 'BiobankSubCategory','BiobankPersonRole');
     161
     162UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='282';
     163UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='283';
     164UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='286';
     165UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='287';
     166UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='288';
     167UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='289';
     168UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='290';
     169UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='291';
     170UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='292';
     171UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='293';
     172UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='295';
     173UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='296';
     174UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='297';
     175UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='298';
     176UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='564';
     177
     178/*below we resolve the problem of duplicate entries in ontology term for PersonRole*/
     179
     180select * from OntologyTerm where name="Software Engineer";
     181delete from OntologyTerm where id=561;
     182select * from BiobankPersonRole;
     183insert into BiobankPersonRole values(561);
     184
     185select * from OntologyTerm where name="coordinator";
     186delete from OntologyTerm where id=593;
     187select * from BiobankPersonRole;
     188insert into BiobankPersonRole values(277);
     189
     190select * from OntologyTerm where name="postdoc";
     191delete from OntologyTerm where id=594;
     192 select * from BiobankPersonRole;
     193insert into BiobankPersonRole values(278);
     194
     195select * from OntologyTerm where name="administrator";
     196delete from OntologyTerm where id=595;
     197select * from BiobankPersonRole;
     198insert into BiobankPersonRole values(279);
     199
     200
     201select * from OntologyTerm where name="IT responsible";
     202delete from OntologyTerm where id=596;
     203select * from BiobankPersonRole;
     204insert into BiobankPersonRole values(280);
     205
     206 
     207COMMIT;
     208
     209
    14210}}}