alter table RESOURCE_ALLOCATION drop column KEY_LESSON_INSTANCE;
alter table LESSON drop column KEY_SALA;

create table WRITTEN_EVALUATION_WRITTEN_EVALUATION_SPACE_OCCUPATION (
	KEY_WRITTEN_EVALUATION int(11) not null,
	KEY_WRITTEN_EVALUATION_SPACE_OCCUPATION int(11) not null,  
	primary key (KEY_WRITTEN_EVALUATION, KEY_WRITTEN_EVALUATION_SPACE_OCCUPATION),
	key(KEY_WRITTEN_EVALUATION),
	key(KEY_WRITTEN_EVALUATION_SPACE_OCCUPATION)
) type=InnoDB;

insert into WRITTEN_EVALUATION_WRITTEN_EVALUATION_SPACE_OCCUPATION (KEY_WRITTEN_EVALUATION, KEY_WRITTEN_EVALUATION_SPACE_OCCUPATION) select KEY_WRITTEN_EVALUATION, ID_INTERNAL from RESOURCE_ALLOCATION where OJB_CONCRETE_CLASS like '%WrittenEvaluationSpaceOccupation%';

alter table RESOURCE_ALLOCATION drop column KEY_WRITTEN_EVALUATION;