use `akura`;
/*!40014 SET UNIQUE_CHECKS=0 */;
/*!40014 SET FOREIGN_KEY_CHECKS=0 */;

--
-- Table structure for table `PARENT`
--
ALTER TABLE `PARENT` 
DROP FOREIGN KEY`fk_PARENT_STAFF1`;

ALTER TABLE `PARENT` 
CHANGE COLUMN `RELATIONSHIP` `RELATIONSHIP` VARCHAR(45) NULL,  

  ADD CONSTRAINT `fk_PARENT_STAFF1`

  FOREIGN KEY (`TEACHER_REG_NO` )

  REFERENCES `STAFF` (`REGISTRATION_NO` )

  ON DELETE RESTRICT

  ON UPDATE NO ACTION ;

--
-- Table structure for table `PUBLICATION`
--
ALTER TABLE `PUBLICATION` 

DROP INDEX `HEADER_UNIQUE` ;



--
-- Table structure for table `EXAM_MARKS`
--
ALTER TABLE `EXAM_MARKS` 
ADD COLUMN `EXAM_ADMISSION_ID` INT(11) NULL DEFAULT NULL  , 
DROP FOREIGN KEY `fk_EXAM_MARKS_STUDENT1`, 
DROP FOREIGN KEY `fk_EXAM_MARKS_GRADING1`, 
DROP FOREIGN KEY `fk_EXAM_MARKS_EXAM_SUBJECT1` ;

ALTER TABLE `EXAM_MARKS` 

  ADD CONSTRAINT `fk_EXAM_MARKS_STUDENT1`

  FOREIGN KEY (`STUDENT_ID` )

  REFERENCES `STUDENT` (`STUDENT_ID` )

  ON DELETE RESTRICT

  ON UPDATE CASCADE, 

  ADD CONSTRAINT `fk_EXAM_MARKS_GRADING1`

  FOREIGN KEY (`GRADING_ID` )

  REFERENCES `GRADING` (`GRADING_ID` )

  ON DELETE RESTRICT

  ON UPDATE CASCADE, 

  ADD CONSTRAINT `fk_EXAM_MARKS_EXAM_ADMISSION1`

  FOREIGN KEY (`EXAM_ADMISSION_ID` )

  REFERENCES `EXAM_ADMISSIONS` (`EXAM_ADMISSION_ID` )

  ON DELETE CASCADE

  ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_EXAM_MARKS_EXAM_SUBJECT1`

  FOREIGN KEY (`EXAM_SUBJECT_ID` )

  REFERENCES `EXAM_SUBJECT` (`EXAM_SUBJECT_ID` )

  ON DELETE RESTRICT

  ON UPDATE RESTRICT ;

--
-- Table structure for table `PRIVILEGE_DEPENDENCY`
--
CREATE  TABLE IF NOT EXISTS `PRIVILEGE_DEPENDENCY` (

  `PRIVILEGE_DEPENDENCY_ID` INT(11) NOT NULL AUTO_INCREMENT ,

  `PRIVILEGE_ID` INT(11) NOT NULL ,

  `DEPENDENCY_ID` INT(11) NOT NULL ,

  `MODIFIED_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,

  PRIMARY KEY (`PRIVILEGE_DEPENDENCY_ID`) ,

  CONSTRAINT `fk_PRIVILEGE_DEPENDENCY_PRIVILEGE1`

    FOREIGN KEY (`PRIVILEGE_ID` )

    REFERENCES `PRIVILEGE` (`PRIVILEGE_ID` )

    ON DELETE RESTRICT

    ON UPDATE RESTRICT,

  CONSTRAINT `fk_PRIVILEGE_DEPENDENCY_DEPENDENCY1`

    FOREIGN KEY (`DEPENDENCY_ID` )

    REFERENCES `PRIVILEGE` (`PRIVILEGE_ID` )

    ON DELETE RESTRICT

    ON UPDATE RESTRICT)

ENGINE = InnoDB

DEFAULT CHARACTER SET = latin1

COLLATE = latin1_swedish_ci;

--
-- Table structure for table `BUSINESS_AUDIT_DETAILS`
--
DROP TABLE `BUSINESS_AUDIT_DETAILS`;

--
-- Table structure for table `BUSINESS_AUDIT`
--
DROP TABLE `BUSINESS_AUDIT`;

--
-- Table structure for table `AUDIT_EVENT_TYPE`
--
CREATE  TABLE IF NOT EXISTS `AUDIT_EVENT_TYPE` (

  `AUDIT_EVENT_TYPE_ID` INT(11) NOT NULL AUTO_INCREMENT ,

  `DESCRIPTION` VARCHAR(45) NOT NULL ,

  `MODIFIED_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,

  PRIMARY KEY (`AUDIT_EVENT_TYPE_ID`) )

ENGINE = InnoDB

DEFAULT CHARACTER SET = latin1

COLLATE = latin1_swedish_ci;

--
-- Table structure for table `BUSINESS_AUDIT`
--
CREATE  TABLE IF NOT EXISTS `BUSINESS_AUDIT` (

  `BUSINESS_AUDIT_ID` INT(11) NOT NULL AUTO_INCREMENT,

  `USER_LOGIN_ID` INT(11) NOT NULL ,

  `DATE` DATETIME NOT NULL ,

  `BUSINESS_FUNCTION` VARCHAR(200) NOT NULL ,

  `MODULE` VARCHAR(200) NOT NULL ,

  `EVENT_TYPE` INT(11) NOT NULL ,

  `MODIFIED_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,

  PRIMARY KEY (`BUSINESS_AUDIT_ID`) ,

  CONSTRAINT `fk_BUSSINESS_AUDIT_USER_LOGIN1`

    FOREIGN KEY (`USER_LOGIN_ID` )

    REFERENCES `USER_LOGIN` (`USER_LOGIN_ID` )

    ON DELETE CASCADE

    ON UPDATE CASCADE,
  CONSTRAINT `fk_BUSSINESS_AUDIT_AUDIT_EVENT1`

    FOREIGN KEY (`EVENT_TYPE` )

    REFERENCES `AUDIT_EVENT_TYPE` (`AUDIT_EVENT_TYPE_ID` )

    ON DELETE CASCADE

    ON UPDATE CASCADE) 

ENGINE = InnoDB

DEFAULT CHARACTER SET = latin1

COLLATE = latin1_swedish_ci;

--
-- Table structure for table `BUSINESS_AUDIT_DETAILS`
--
CREATE  TABLE IF NOT EXISTS `BUSINESS_AUDIT_DETAILS` (

  `BUSINESS_AUDIT_DETAILS_ID` INT(11) NOT NULL AUTO_INCREMENT,

  `BUSINESS_AUDIT_ID` INT(11) NOT NULL ,

  `ATTRIBUTE_NAME` VARCHAR(200) NOT NULL ,

  `AUDIT_DESCRIPTION` VARCHAR(1000) NOT NULL ,

  `MODIFIED_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,

  PRIMARY KEY (`BUSINESS_AUDIT_DETAILS_ID`) ,

  CONSTRAINT `fk_BUSSINESS_AUDIT_DETAILS_BUSSINESS_AUDIT1`

    FOREIGN KEY (`BUSINESS_AUDIT_ID` )

    REFERENCES `BUSINESS_AUDIT` (`BUSINESS_AUDIT_ID` )

    ON DELETE CASCADE

    ON UPDATE CASCADE)

ENGINE = InnoDB

DEFAULT CHARACTER SET = latin1

COLLATE = latin1_swedish_ci;

--
-- Table structure for table `STUDENT_PARENT`
--
ALTER TABLE `STUDENT_PARENT` 
ADD UNIQUE INDEX `UC_STUDENT_PARENT_RELATIONSHIP` (`STUDENT_ID` ASC, `RELATIONSHIP` ASC) ;

/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
/*!40014 SET UNIQUE_CHECKS=1 */;