CREATE TABLE ANNULLED_GRADE_BOOK_SHEET (
  ID_INTERNAL int(11) NOT NULL,
  NUMBER int(3) NOT NULL,
  REASON text NOT NULL,
  REGULARIZED TINYINT(1) DEFAULT 0 NOT NULL,
  MARK_SHEET_TYPE text NOT NULL,
  CHECK_SUM text NOT NULL,
  EVALUATION_DATE_DATE_TIME DATETIME NOT NULL,
  CREATION_ENTITY text NOT NULL,
  CREATION_ENTITY_DATE date NOT NULL,
  UPDATE_ENTITY text,
  UPDATE_ENTITY_DATE DATETIME default NULL,
  KEY_GRADE_BOOK_VOLUME int(11) NOT NULL,
  KEY_ROOT_DOMAIN_OBJECT int(11) default '1' NOT NULL,
  KEY_ANNULLED_BY_EMPLOYEE int(11) NOT NULL,
  KEY_CURRICULAR_COURSE int(11) NOT NULL,
  KEY_EXECUTION_PERIOD int(11) NOT NULL,
  KEY_RESPONSIBLE_TEACHER int(11) NOT NULL,
  PRIMARY KEY  (ID_INTERNAL)
);
ALTER TABLE ANNULLED_GRADE_BOOK_SHEET MODIFY ID_INTERNAL INT NOT NULL AUTO_INCREMENT;
ALTER TABLE ANNULLED_GRADE_BOOK_SHEET ADD INDEX KEY_ROOT_DOMAIN_OBJECT(KEY_ROOT_DOMAIN_OBJECT);
ALTER TABLE ANNULLED_GRADE_BOOK_SHEET ADD INDEX KEY_GRADE_BOOK_VOLUME(KEY_GRADE_BOOK_VOLUME);
ALTER TABLE ANNULLED_GRADE_BOOK_SHEET ADD INDEX KEY_ANNULLED_BY_EMPLOYEE(KEY_ANNULLED_BY_EMPLOYEE);
ALTER TABLE ANNULLED_GRADE_BOOK_SHEET ADD INDEX KEY_CURRICULAR_COURSE(KEY_CURRICULAR_COURSE);
ALTER TABLE ANNULLED_GRADE_BOOK_SHEET ADD INDEX KEY_EXECUTION_PERIOD(KEY_EXECUTION_PERIOD);
ALTER TABLE ANNULLED_GRADE_BOOK_SHEET ADD INDEX KEY_RESPONSIBLE_TEACHER(KEY_RESPONSIBLE_TEACHER);

CREATE TABLE ANNULLED_GRADE_BOOK_LINE (
  ID_INTERNAL int(11) NOT NULL,
  REGISTRATION_NUMBER int(11) NOT NULL,
  DELETED TINYINT(1) DEFAULT 0 NOT NULL,
  CHECK_SUM text NOT NULL,
  ENROLMENT_EVALUATION_TYPE text NOT NULL,
  EXAM_DATE_YEAR_MONTH_DAY text NOT NULL,
  GRADE VARCHAR(50) NOT NULL,
  GRADE_VALUE VARCHAR(11) NOT NULL,
  OBSERVATION text,
  ENROLMENT_DATE DATE,
  SEASON VARCHAR(30),
  CREATION_ENTITY text NOT NULL,
  CREATION_ENTITY_DATE date NOT NULL,
  UPDATE_ENTITY text,
  UPDATE_ENTITY_DATE DATETIME default NULL,
  KEY_ANNULLED_GRADE_BOOK_SHEET int(11) NOT NULL,
  KEY_ROOT_DOMAIN_OBJECT int(11) default '1' NOT NULL,
  KEY_PERSON int(11) NOT NULL,
  PRIMARY KEY  (ID_INTERNAL)
);
ALTER TABLE ANNULLED_GRADE_BOOK_LINE MODIFY ID_INTERNAL INT NOT NULL AUTO_INCREMENT;
ALTER TABLE ANNULLED_GRADE_BOOK_LINE ADD INDEX KEY_ROOT_DOMAIN_OBJECT(KEY_ROOT_DOMAIN_OBJECT);
ALTER TABLE ANNULLED_GRADE_BOOK_LINE ADD INDEX KEY_ANNULLED_GRADE_BOOK_SHEET(KEY_ANNULLED_GRADE_BOOK_SHEET);
ALTER TABLE ANNULLED_GRADE_BOOK_LINE ADD INDEX KEY_PERSON(KEY_PERSON);
