   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);

(
  ID                          BIGINT      NOT NULL,
  PROTOCOL_ID                 BIGINT      NOT NULL,
  PRIMARY KEY                 (ID)
);


  PRIMARY KEY                 (INVESTIGATION_ID, TERM_ID)
);

CREATE TABLE CHARACTERISTIC
(
  ID                          BIGINT      NOT NULL,
  VALUE                       VARCHAR(1000),
  TERM_ID                     BIGINT,
  UNIT_ID                     BIGINT,
  BIOMATERIAL_ID              BIGINT,
  PRIMARY KEY                 (ID)
);

CREATE TABLE COMPOUND
(
  ID                          BIGINT      NOT NULL,
  PRIMARY KEY                 (ID)
);

CREATE TABLE BIOMATERIAL
(
  ID                          BIGINT      NOT NULL,
  NAME                        VARCHAR(1000),
  DESCRIPTION                 VARCHAR(1000),
  MATERIAL_TYPE_ID            BIGINT,
  LABEL_ID                    BIGINT,
  DISCRIMINATOR               VARCHAR(5),
  PRIMARY KEY                 (ID)
);

CREATE TABLE SOURCEPROVIDER
(
  SOURCE_ID                   BIGINT      NOT NULL,
  CONTACT_ID                  BIGINT      NOT NULL,
  PRIMARY KEY                 (SOURCE_ID, CONTACT_ID)
);

CREATE TABLE SOURCESAMPLE
(
  SOURCE_ID                   BIGINT      NOT NULL,
  SAMPLE_ID                   BIGINT      NOT NULL,
  PRIMARY KEY                 (SOURCE_ID, SAMPLE_ID)
);

CREATE TABLE SAMPLEEXTRACT
(
  SAMPLE_ID                   BIGINT      NOT NULL,
  EXTRACT_ID                  BIGINT      NOT NULL,
  PRIMARY KEY                 (SAMPLE_ID, EXTRACT_ID)
);

CREATE TABLE EXTRACTLABELEDEXTRACT
(
  EXTRACT_ID                  BIGINT      NOT NULL,
  LABELEDEXTRACT_ID           BIGINT      NOT NULL,
  PRIMARY KEY                 (EXTRACT_ID, LABELEDEXTRACT_ID)
);

ALTER TABLE TERM
  ADD FOREIGN KEY(CATEGORY_ID)
  REFERENCES CATEGORY(ID);
