CREATE TABLE `THESIS_EVALUATION_PARTICIPANT` (
  `ID_INTERNAL` INTEGER NOT NULL auto_increment,
  `KEY_PERSON` INTEGER NOT NULL,
  `KEY_THESIS` INTEGER NOT NULL,
  `KEY_CATEGORY` INTEGER,
  `AFFILIATION` TEXT,
  `TYPE` VARCHAR(255) NOT NULL,
  PRIMARY KEY  (`ID_INTERNAL`),
  KEY `KEY_PERSON` (`KEY_PERSON`)
);

insert into THESIS_EVALUATION_PARTICIPANT (KEY_PERSON, KEY_THESIS, TYPE)
select THESIS.KEY_ORIENTATOR, THESIS.ID_INTERNAL, 'ORIENTATOR' from THESIS WHERE THESIS.KEY_ORIENTATOR IS NOT NULL;

insert into THESIS_EVALUATION_PARTICIPANT (KEY_PERSON, KEY_THESIS, TYPE)
select THESIS.KEY_COORIENTATOR, THESIS.ID_INTERNAL, 'COORIENTATOR' from THESIS WHERE THESIS.KEY_COORIENTATOR IS NOT NULL;

insert into THESIS_EVALUATION_PARTICIPANT (KEY_PERSON, KEY_THESIS, TYPE)
select THESIS.KEY_PRESIDENT, THESIS.ID_INTERNAL, 'PRESIDENT' from THESIS WHERE THESIS.KEY_PRESIDENT IS NOT NULL;

insert into THESIS_EVALUATION_PARTICIPANT (KEY_PERSON, KEY_THESIS, TYPE)
select THESIS_JURY_VOWELS.KEY_PERSON, THESIS_JURY_VOWELS.KEY_THESIS, 'VOWEL' from THESIS_JURY_VOWELS;

drop table THESIS_JURY_VOWELS;

ALTER TABLE `THESIS`
	DROP COLUMN `KEY_ORIENTATOR`,
	DROP COLUMN `KEY_COORIENTATOR`,
	DROP COLUMN `KEY_PRESIDENT`;
