   ADD FOREIGN KEY(PROTOCOL_ID)
   REFERENCES PROTOCOL(ID);
 
+ALTER TABLE PROTOCOLAPPLICATION
+  ADD FOREIGN KEY(BIOMATERIAL_ID)
+  REFERENCES BIOMATERIAL(ID);
+
 ALTER TABLE PARAMETERVALUE
   ADD FOREIGN KEY(PROTOCOL_APPLICATION_ID)
   REFERENCES PROTOCOLAPPLICATION(ID);

DROP TABLE IF EXISTS NORMALIZATIONTYPE;
DROP TABLE IF EXISTS REPLICATETYPE;
DROP TABLE IF EXISTS QUALITYCONTROLTYPE;

CREATE TABLE TERM
(


CREATE INDEX QUALCTRLTYPE_TERM_IDX ON QUALITYCONTROLTYPE(TERM_ID);

CREATE INDEX CHARACTERISTIC_TERM_IDX ON CHARACTERISTIC(TERM_ID);

CREATE INDEX CHARACTERISTIC_UNIT_IDX ON CHARACTERISTIC(UNIT_ID);

CREATE INDEX CHARACTERISTIC_BIOMATERIAL_IDX ON CHARACTERISTIC(BIOMATERIAL_ID);

CREATE INDEX BIOMATERIAL_TYPE_IDX ON BIOMATERIAL(BIOMATERIAL_TYPE_ID);

CREATE INDEX BIOMATERIAL_LABEL_IDX ON BIOMATERIAL(LABEL_ID);

CREATE INDEX SOURCEPROVIDER_SOURCE_IDX ON SOURCEPROVIDER(SOURCE_ID);

CREATE INDEX SOURCEPROVIDER_CONTACT_IDX ON SOURCEPROVIDER(CONTACT_ID);

CREATE INDEX SOURCESAMPLE_SOURCE_IDX ON SOURCESAMPLE(SOURCE_ID);

CREATE INDEX SOURCESAMPLE_SAMPLE_IDX ON SOURCESAMPLE(SAMPLE_ID);

CREATE INDEX SAMPLEEXTRACT_SAMPLE_IDX ON SAMPLEEXTRACT(SAMPLE_ID);

CREATE INDEX SAMPLEEXTRACT_EXTRACT_IDX ON SAMPLEEXTRACT(EXTRACT_ID);

CREATE INDEX EXTRACTLABELEDEXTRACT_E_IDX ON EXTRACTLABELEDEXTRACT(EXTRACT_ID);

CREATE INDEX EXTRACTLABELEDEXTRACT_LE_IDX ON EXTRACTLABELEDEXTRACT(LABELEDEXTRACT_ID);

SET FOREIGN_KEY_CHECKS = 1;
