Changes between Version 5 and Version 6 of DespoinaLog_molgenis35Tomolgenis14


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

--

Legend:

Unmodified
Added
Removed
Modified
  • DespoinaLog_molgenis35Tomolgenis14

    v5 v6  
    103103COMMIT;
    104104
    105 ======================================================================================
    106 SubCategory
    107 biobank_ibfk_1
    108   CONSTRAINT `biobank_ibfk_5` FOREIGN KEY (`SubCategory`) REFERENCES `BiobankSubCategory` (`id`)
    109   CONSTRAINT `biobank_ibfk_5` FOREIGN KEY (`SubCategory`) REFERENCES `BiobankSubCategory` (`id`),
    110 
    111 
    112 =============================WITH COMMENTS ===========================================
    113 
    114 CREATE TABLE `BiobankSubCategory` (
    115   `id` int(11) NOT NULL,
    116   PRIMARY KEY (`id`),
    117   CONSTRAINT `biobanksubcategory_ibfk_1` FOREIGN KEY (`id`) REFERENCES `OntologyTerm` (`id`) ON DELETE CASCADE
    118 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
    119 
    120 /* move data from BiobankCategory to BiobankSubCategory table */
    121 INSERT INTO BiobankSubCategory (id)
    122 SELECT id
    123 FROM BiobankCategory
    124 WHERE id  NOT IN ("281", "284", "285") ;
    125 /*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/
    126 
    127 /* alter constraints */
    128 ALTER TABLE Biobank DROP FOREIGN KEY biobank_ibfk_5;
    129 
    130 
    131 ALTER TABLE BiobankSubCategory ADD FOREIGN KEY (id) REFERENCES OntologyTerm (id) ON DELETE CASCADE;
    132 NOT OK : ERROR 1050 (42S01): Table './bbmri/BiobankSubCategory' already exists
    133 THEN USE : 
    134 ALTER TABLE `BiobankSubCategory` 
    135 ADD CONSTRAINT `id`
    136     FOREIGN KEY (`id`) REFERENCES OntologyTerm (id) ON DELETE CASCADE;
    137 
    138 ALTER TABLE Biobank ADD FOREIGN KEY (SubCategory) REFERENCES BiobankSubCategory (id) ON DELETE RESTRICT;
    139 NOT OK : ERROR 1050 (42S01): Table './bbmri/Biobank' already exists
    140 THEN USE :
    141 ALTER TABLE `Biobank` 
    142 ADD CONSTRAINT `SubCategory`
    143     FOREIGN KEY (`SubCategory`) REFERENCES BiobankSubCategory (id)  ON DELETE CASCADE;
    144 
    145 
    146 
    147 /* delete moved data from BiobankCategory */
    148 DELETE FROM BiobankCategory
    149 WHERE id  NOT IN ("281", "284", "285") ;   
    150 /*IF NEEDED CORRECT THE IDs
    151 WHERE name IN ("A. Core Biobanks, DNA available", "B: Supporting biobanks, DNA not yet available" ,"C: Biobanken in opbouw") ;
    152 */
    153 
    154 CREATE TABLE BiobankPersonRole (
    155         id INTEGER NOT NULL
    156         , PRIMARY KEY(id)
    157 );
    158 
    159 ALTER TABLE BiobankPersonRole ADD FOREIGN KEY (id) REFERENCES PersonRole (id) ON DELETE CASCADE;
    160 
    161 alter table OntologyTerm modify   column __Type enum('OntologyTerm','PersonRole','Species','AlternateId','BiobankCategory','BiobankTopic','BiobankDataType', 'BiobankSubCategory','BiobankPersonRole');
    162 
    163 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='282';
    164 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='283';
    165 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='286';
    166 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='287';
    167 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='288';
    168 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='289';
    169 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='290';
    170 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='291';
    171 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='292';
    172 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='293';
    173 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='295';
    174 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='296';
    175 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='297';
    176 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='298';
    177 UPDATE OntologyTerm  SET __Type="BiobankSubCategory" WHERE id='564';
    178 
    179 /*below we resolve the problem of duplicate entries in ontology term for PersonRole*/
    180 
    181 select * from OntologyTerm where name="Software Engineer";
    182 delete from OntologyTerm where id=561;
    183 select * from BiobankPersonRole;
    184 insert into BiobankPersonRole values(561);
    185 
    186 select * from OntologyTerm where name="coordinator";
    187 delete from OntologyTerm where id=593;
    188 select * from BiobankPersonRole;
    189 insert into BiobankPersonRole values(277);
    190 
    191 select * from OntologyTerm where name="postdoc";
    192 delete from OntologyTerm where id=594;
    193  select * from BiobankPersonRole;
    194 insert into BiobankPersonRole values(278);
    195 
    196 select * from OntologyTerm where name="administrator";
    197 delete from OntologyTerm where id=595;
    198 select * from BiobankPersonRole;
    199 insert into BiobankPersonRole values(279);
    200 
    201 
    202 select * from OntologyTerm where name="IT responsible";
    203 delete from OntologyTerm where id=596;
    204 select * from BiobankPersonRole;
    205 insert into BiobankPersonRole values(280);
    206 
    207  
    208 COMMIT;
    209 
     105=============
    210106
    211107}}}